HyderA
HyderA

Reputation: 21411

Yii CGridView - What AJAX response is expected?

The CGridView component has an ajaxUrl property. I don't fully understand what kind of response is expected from the url. Is it a rendered HTML to replace the existing component? Is it JSON data or the dataprovider?

EDIT: Or are we expected to manually implement a data handler?

Upvotes: 0

Views: 742

Answers (1)

darkheir
darkheir

Reputation: 8960

This is some HTML corresponding to the CGridView. For example in the controller you could put:

if(Yii::app()->request->isAjaxRequest) {
    $this->renderPartial('_yourGridView',array(
            'model' => $model,
    ));
    Yii::app()->end();
}

Where _yourGridView is a view containing my CGridView widgets

Note also that the ajaxUrl is necessary only if the url is different than the current one. If you want to use the same url (so the same controller and the same action) you don't have to specify it

Upvotes: 2

Related Questions