2016-03-07 97 views
0

我已經嘗試使用array_filter(),但它仍然不適用於已發佈/未發佈的列。其實我想隱藏其移動圖標欄時,搜索字段不爲空yii如何在yii網格列表中搜索列時如何隱藏列

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

我們可以使用strlen作爲array_filter的回調函數() – Mahen

回答

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