本文介绍了Yii的CGridView内CJuiDialog渲染不会被过滤或订购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我渲染CGridView内CJuiDialog,这是工作的罚款。

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

我的问题是,我每次单击列标题排序记录,页面的变化(URL是通过AJAX呈现与的RenderPartial视图的URL)和请求不是阿贾克斯(的Yii ::应用​​程序() - >请求 - > isAjaxRequest 里面的控制器是假的)

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.

我怎样才能让用户排序或筛选CGridView?

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

OR:有另一种方式,让用户通过CGridView?

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

推荐答案

我终于找到了解决办法。

I finally found the solution.

当你打电话的RenderPartial必须将第三个参数= FALSE和第四个参数= TRUE。

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:

$符 布尔的渲染结果是否应该返回,而不是最终用户显示 $ processOutput 布尔的是否渲染结果都应该用processOutput进行后处理。

$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.

和最重要的TWEAK:里面的景色呈现与您的RenderPartial必须添加:

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

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

该页面重新加载简单的原因:jQuery是加载多次。

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

这篇关于Yii的CGridView内CJuiDialog渲染不会被过滤或订购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 10:08