[英]Yii CGridView renders a new page instead of AJAX
In the index page of my site I have floating div-block with CGridView inside. 在我网站的索引页面中,我的浮动div块内部带有CGridView。
I need to use sort, filter, paging etc. options, but only via updating this only div and not refreshing the whole page. 我需要使用排序,过滤,分页等选项,但只能通过更新此唯一的div而不刷新整个页面。
Data rendering as it should, i'm stuck only with updating grid contents - all <a>
's have href, that sending user to specified view. 数据呈现应有的表现,我只限于更新网格内容-所有
<a>
都具有href,即将用户发送到指定的视图。
Here's the view for grid: (it's the only content of my views.users.usersGrid.php) 这是网格视图:(这是我的views.users.usersGrid.php的唯一内容)
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'filter' => $model,
'ajaxUrl' => 'modules/subcntrl/usersGrid',
'ajaxUpdate' => 'users-grid',
'columns' => array(
array(
'name' => 'name',
'type' => 'raw',
'value' => 'CHtml::encode($data->name)'
),
array(
'class'=>'CButtonColumn',
),
),
));
It's called from views.users.users.php: <?php $this->actionUsersGrid(); ?>
它是从views.users.users.php中调用的:
<?php $this->actionUsersGrid(); ?>
<?php $this->actionUsersGrid(); ?>
Controller: 控制器:
public function actionUsers() {
$this->renderPartial('users');
}
public function actionUsersGrid() {
if(!Yii::app()->request->isAjaxRequest) die('Url should be requested via ajax only');
$model = new Users();
$this->renderPartial('usersGrid',array(
'model' => $model,
));
}
Would appreciate any help 希望有帮助
please use the third and fouth parameter in renderPartial
method like this, 请在
renderPartial
方法中使用第三个参数renderPartial
,
$this->renderPartial('users',array(),false,true);
it will solve your problem (setting the processOutput=true
) in the fourth parameter 它将在第四个参数中解决您的问题(设置
processOutput=true
)
please use the third and fouth parameter in renderPartial method like this, 请在renderPartial方法中使用第三个参数fouth,
$this->renderPartial('users',array(),false,true);
it will solve your problem (setting the processOutput=true
) in the fourth parameter 它将在第四个参数中解决您的问题(设置
processOutput=true
)
this is not working in my code. 这在我的代码中不起作用。 i am using like this in ma controler
我在马控制器中使用这样的
$this->renderPartial('_searchQuote', array('model' => $model, 'month' => $month, 'user' => $user), false, $processOutput=false );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.