我知道我們可以顯示一個模型的gridview,它是搜索方法和過濾結果,但我們可以使用另一個數據提供者和另一個模型這樣做一個gridview並篩選其結果?過濾器是否需要成爲數據提供者的一部分?yii CGridView數據提供者和過濾器
$attr = Yii::app()->request->getParam($name);
$model = new User('search');
$model->unsetAttributes();
$model->setAttributes($attr);
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $myDataProvider,
'filter' => $model,
'columns' => array(
array(
'name' => 'username',
'type' => 'raw',
'value' => 'CHtml::encode($data->username)'
),
array(
'name' => 'email',
'type' => 'raw',
),
),
));
上述代碼不起作用,我需要在以前製作的數據提供程序上添加一個過濾器。
btw $attr
有一個有效的數據,但網格不被過濾。
如果其中一個標準有一個「連接」屬性,另一個屬性是「有」屬性,你會遇到麻煩,對吧? – tinybyte