【发布时间】:2014-02-25 12:25:54
【问题描述】:
我正在使用 CGridView 来显示 postgres 函数的结果。 CGridView 工作正常。现在我想在模型中使用不同的函数来过滤 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(),
..............
$model->search() 函数接受一个用于从表中选择行的 id。我正在使用 CSqlDataProvider 在 $model->search() 中运行自定义查询并返回数据提供程序。如果我使用上面的代码,它将显示 CGridView 中所有字段的过滤器文本框。但是搜索功能使用的 id 没有显示在 CGridView 中。所以过滤不起作用。所以我想使用一个新的过滤函数来接受过滤字段。我尝试使用下面的代码
$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() 返回什么?什么数据类型?
标签: yii