我正在为我的网络应用程序使用 yii。在我的一个观点中,我有 CGridView 和 dataprovider 是邮件模型。在这个模型中,我与其他 3 个模型有关系。在网格中,我显示了三个模型的 cols。如何过滤 CGridView?
更新:
<?php $dialog = $this->widget('ext.ecolumns.EColumnsDialog', array(
'options'=>array(
'title' => 'Layout settings',
'autoOpen' => false,
'show' => 'fade',
'hide' => 'fade',
),
'htmlOptions' => array('style' => 'display: none'), //disable flush of dialog content
'ecolumns' => array(
'gridId' => 'mails-grid', //id of related grid
'storage' => 'session', //where to store settings: 'db', 'session', 'cookie'
'fixedLeft' => array('CCheckBoxColumn'), //fix checkbox to the left side
'model' => $dataprovider, //model is used to get attribute labels
'columns'=>array(
array(
'name'=>'mailTemplate.name',
'filter'=>CHtml::activeTextField($dataprovider, 'mailTemplate'),
),
'sendDate',
array(
'name'=>'mailTemplate.subject',
'filter'=>CHtml::activeTextField($dataprovider, 'mailTemplate'),
),
array(
'name'=>'client.email',
'filter'=>CHtml::activeTextField($dataprovider, 'client'),
),
array(
'name'=>'client.name',
'filter'=>CHtml::activeTextField($dataprovider, 'client'),
),
array(
'name'=>'operator.username',
'filter'=>CHtml::activeTextField($dataprovider, 'operator'),
),
array(
'name'=>'status',
'value'=>array('MailHelper', 'getEmailStatus'),
'filter'=> CHtml::activeDropDownList($dataprovider, 'status', Mail::getEmailStatuses()),
),
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'buttons'=>array(
'update' => array(
'url'=>'$this->grid->controller->createUrl("/email/editTemplate", array("templateId"=>$data->id))',
),
),
)
),
)
));
?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'mails-grid',
'dataProvider'=>$dataprovider->search(),
'columns' => $dialog->columns(),
'filter' => $dataprovider,
'template' => $dialog->link()."{summary}\n{items}\n{pager}",
)); ?>