问题
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?
回答1:
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?
回答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.
来源:https://stackoverflow.com/questions/23635727/yii-cgridview-rendered-inside-cjuidialog-wont-be-filtered-or-ordered