yii如何在yii网格列表中搜索时隐藏列

时间:2016-03-07 12:30:27

标签: php yii

  

我尝试过使用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,
    ));
}

1 个答案:

答案 0 :(得分:0)

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,
    ));
}