【问题标题】:yii how to hide a column in case of search in yii grid listyii如何在yii网格列表中搜索时隐藏列
【发布时间】:2016-03-07 12:30:26
【问题描述】:

我已尝试使用 array_filter(),但它仍然不适用于已发布/未发布的列。实际上,当搜索字段不为空时,我想隐藏具有移动图标的列

public function actionAdmin()
{
    $model=new InfoCategories('search');
    $model->unsetAttributes();  // clear any default values
    $model->del_flg=0;
    $enableSorting = TRUE;
    if (isset($_GET['InfoCategories'])) {
        $model->attributes=$_GET['InfoCategories'];
        if(array_filter($_GET['InfoCategories'])){
            $enableSorting = FALSE;
        }
    }

    $statusList = array("0"=>t("common","UnPublished"), "1"=>t("common","Published"));
    $this->render('admin',array(
        'model'=>$model,
        'statusList'=>$statusList,
        'enableSorting'=> $enableSorting,
    ));
}

【问题讨论】:

  • 我们可以在array_filter()中使用strlen作为回调函数

标签: php yii


【解决方案1】:
public function actionAdmin()
{
    $model=new InfoCategories('search');
    $model->unsetAttributes();  // clear any default values
    $model->del_flg=0;
    $enableSorting = TRUE;
    if (isset($_GET['InfoCategories'])) {
        $model->attributes=$_GET['InfoCategories'];
        if(array_filter($_GET['InfoCategories'], 'strlen')){
            $enableSorting = FALSE;
        }
    }

    $statusList = array("0"=>t("common","UnPublished"), "1"=>t("common","Published"));
    $this->render('admin',array(
        'model'=>$model,
        'statusList'=>$statusList,
        'enableSorting'=> $enableSorting,
    ));
}

【讨论】:

    猜你喜欢
    • 2012-04-14
    • 2012-08-23
    • 1970-01-01
    • 2012-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 2020-06-14
    相关资源
    最近更新 更多