我正在使用CGridView顯示來自postgres函數的結果。 CGridView工作正常。現在我想在模型中使用不同的函數來過濾CGridView。在yii中爲Cgridview定製過濾
爲CGridView當前碼是像
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'purchase-grid',
'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',
'filter'=>$model,
'dataProvider'=>$model->search(),
..............
的$模型 - >搜索()函數接受它用來從表中選擇的行的ID。我正在使用CSqlDataProvider在$ model-> search()中運行自定義查詢並返回數據提供者。如果我使用上面的代碼,它將顯示CGridView中所有字段的過濾器文本框。但是搜索功能正在使用一個沒有顯示在CGridView中的ID。所以過濾不起作用。所以我想使用一個新的函數進行過濾,它將接受過濾的字段。我試着用下面的代碼
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'purchase-grid',
'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',
'filter'=>$model->filter_search(),
'dataProvider'=>$model->search(),
..............
但它顯示錯誤。請幫忙。
在此先感謝。
你的方法$ model-> filter_search()返回什麼?什麼數據類型? – gSorry