Domanda

I'm rendering a CGridView inside a CJuiDialog, and that's working fine.

My problem is, every time i click a column header to sort records, the page changes (the url is the url of the view rendered with renderPartial through ajax) and the request is not ajax ( Yii::app()->request->isAjaxRequest inside the controller is false).

Also, if i filter any field, nothing happens.

How can I let the user sort or filter the CGridView?

OR: Is there another way to let the user choose a Foreign Key field through a CGridView?

È stato utile?

Soluzione 2

I finally found the solution.

When you call renderPartial you must set the 3rd parameter = FALSE and the 4th parameter = TRUE.

$this->renderPartial('ajax_view',array(
            'model'=>$model,
            'dataProvider'=>$dataProvider,
            ),false,TRUE);

From the official documentation:

$return boolean whether the rendering result should be returned instead of being displayed to end users $processOutput boolean whether the rendering result should be postprocessed using processOutput.

And the MOST IMPORTANT TWEAK: Inside the view rendered with renderPartial you must add:

Yii::app()->clientscript->scriptMap['jquery.js'] = false;

The page is reloaded simply 'cause jquery was loaded multiple times.

Altri suggerimenti

This issue probably is happening because a javascript error, or the click function on your code is being override (and not returning false). Could you show your code?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top