Yii CGridView rendered inside CJuiDialog won't be filtered or ordered

流过昼夜 提交于 2019-12-08 13:30:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!