CArrayDataProvider Object
(
[keyField] =>
[rawData] => Array
(
[24] => Array
(
[ids] => 24
[name] => trillia
)
[25] => Array
(
[ids] => 25
[name] => ahestina
)
[28] => Array
(
[ids] => 28
[name] => piyas
)
[59] => Array
(
[ids] => 59
[name] => sitesrs
)
[60] => Array
(
[ids] => 60
[name] => simons
)
[70] => Array
(
[ids] => 70
[name] => Mahesh Raj
)
[71] => Array
(
[ids] => 71
[name] => kathetrine
)
[72] => Array
(
[ids] => 72
[name] => babig
)
[73] => Array
(
[ids] => 73
[name] => symons
)
)
[caseSensitiveSort] => 1
[_id:CDataProvider:private] =>
[_data:CDataProvider:private] =>
[_keys:CDataProvider:private] =>
[_totalItemCount:CDataProvider:private] =>
[_sort:CDataProvider:private] =>
[_pagination:CDataProvider:private] => CPagination Object
(
[pageVar] => page
[route] =>
[params] =>
[validateCurrentPage] => 1
[_pageSize:CPagination:private] => 10
[_itemCount:CPagination:private] => 0
[_currentPage:CPagination:private] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
从上面的数组中我使用视图文件中的以下代码填充cgridview
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'unen-custom-module-grid',
'dataProvider'=>$unenrollProvider,
//'dataProvider'=>Yii::app()->globals->getUsersByStandardnSection(1,3),
'itemsCssClass'=>'table table-striped flip-scroll',
'ajaxUpdate'=>true,
'template'=>'{summary}{pager}{items}{summary}{pager}',
'pager'=>array(
'header' => '',
'firstPageLabel' => '<<',
'prevPageLabel' => 'PREVIOUS',
'nextPageLabel' => 'NEXT',
'lastPageLabel' => '>>',
),
// 'selectableRows' => 2,
'columns'=>array(
array(
'header'=>'#',
'value'=>'++$row',
'htmlOptions'=>array(
'style'=>'width:50px;'
)
),
'name',
array(
'id' => 'unselectedIds',
// 'name' => 'ids',
'selectableRows' => 2,
'class' => 'CCheckBoxColumn',
//'value'=>'$this->ids'
),
),
));
?>
它工作正常,但每当我点击分页时cgridview会自动隐藏,我不在这里使用$ model-&gt; search(),
答案 0 :(得分:1)
每次cgridview分页只发送get请求,而表单发布数据你不能一次又一次地填充cgrid,所以尝试将值存储在session中并访问它,我希望它对你有用,试试吧< / p>
答案 1 :(得分:0)
CGridView需要CActiveDataProvider返回的结果,所以尝试使用CActiveDataProvider在相应模型的搜索方法中执行此操作
答案 2 :(得分:0)
我认为您在此处遇到问题,因为您未在数据提供商中指定keyField
。创建数据提供程序实例时尝试array('keyField'=>'ids)
。另请参阅this answer。