问题描述
我在另一个 cgridview 中有一个 cgridview:外面的一个是:
I have one cgridview inside another cgridview:the outer one is:
$this->widget('application.modules.user.components.CsvGridView', array(
'dataProvider'=>$model->mySearch(),
'filter' => $model,
'id'=>'users-grid',
...
内部是:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'vacr-grid',
'dataProvider'=>$model->searchu(),
// 'pager'=>false,
// 'enableSorting'=>false,
'summaryText'=>'',
'ajaxUpdate'=>'vacr-grid',
'columns'=>array(
'start',
'end',
array(
'name' => 'vac_type',
'value' =>
'isset($data->vacType->name)?$data->vacType->name:$data->vac_type'
),
),
));
问题是内部更新不正常(当然是用ajax更新).
The problem is that the inner one does not update properly (of course update with ajax).
例如,当我单击下一步"时,在内部 cgridview 中,请求的 URL 是:请求 URL:http://localhost/orm/vac/vac/adminu/user_id/1/Vac_page/2?ajax=用户网格
请注意,用户网格是外部 cgridview 的 ID.然后在我点击下一步"后,内部和外部 cgridviews 都消失了.
when I click on "next" for example, in the inner cgridview, the requested URL is: Request URL:http://localhost/orm/vac/vac/adminu/user_id/1/Vac_page/2?ajax=users-grid
notice that users-grid is the id of the outer cgridview.and then after I click on "next" the inner and the outer cgridviews both disappears.
我尝试使用 ajaxUpdate 属性 但它没有影响任何事情.谢谢.
I try to use ajaxUpdate property but it does not affect anything.thank you.
推荐答案
这与我遇到的问题类似.排序和分页 url 由 dataProvider 设置,而搜索 url 由 ajaxUrl 设置.您必须将所有 3 项设置为脱离上下文使用 CGridView.
This is a similar issue to one I was having. The sort and paging urls are set by the dataProvider whereas the search url is set by ajaxUrl. You have to set all 3 to use CGridView out of context.
单独设置数据提供者:
$dataProvider=new CActiveDataProvider('Modelname',array(
'criteria'=>$criteria,
'pagination'=>array(
'route'=>'something/search'
),
'sort'=>array(
'route'=>'something/search'
)
));
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'vacr-grid',
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'ajaxUpdate'=>'vacr-grid', // not necessary if same as id
'ajaxUrl'=>Yii::app()->createUrl( 'Something/search' ), // this takes care of the search
'columns'=>array(
'start',
'end',
array(
'name' => 'vac_type',
'value' =>
'isset($data->vacType->name)?$data->vacType->name:$data->vac_type'
),
),
));
还有我类似的问题...
Also my similar question...
我该怎么做在 Yii 中使用 CGridView 的 ajaxUrl 参数?
这篇关于Yii cgridview ajaxUpdate 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!