簡體   English   中英

Yii CGridView呈現一個新頁面而不是AJAX

[英]Yii CGridView renders a new page instead of AJAX

在我網站的索引頁面中,我的浮動div塊內部帶有CGridView。

我需要使用排序,過濾,分頁等選項,但只能通過更新此唯一的div而不刷新整個頁面。

數據呈現應有的表現,我只限於更新網格內容-所有<a>都具有href,即將用戶發送到指定的視圖。

這是網格視圖:(這是我的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',
        ),
    ),
));

它是從views.users.users.php中調用的: <?php $this->actionUsersGrid(); ?> <?php $this->actionUsersGrid(); ?>

控制器:

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,
    ));
}

希望有幫助

請在renderPartial方法中使用第三個參數renderPartial

$this->renderPartial('users',array(),false,true);

它將在第四個參數中解決您的問題(設置processOutput=true

請在renderPartial方法中使用第三個參數fouth,

$this->renderPartial('users',array(),false,true);

它將在第四個參數中解決您的問題(設置processOutput=true

這在我的代碼中不起作用。 我在馬控制器中使用這樣的

$this->renderPartial('_searchQuote', array('model' => $model, 'month' => $month, 'user' => $user), false, $processOutput=false );      

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM