Ajax Request Of Cgridview On Modal Dialog Window

Hi to everyone,

I have problem with CGridView’s Ajax filtering, sorting, updating on dialog window.

At first openning all of this are working as expected, but then after each reopening dialog window it make more and more ajax calls to server. All of this I watched on firebug. let me be clear. At first openning and click sorting field, it make one request. after reopening dialog window and click sorting field, it make two request to server and etc.

Who have faced with this problem and how you solve it?

ps: sorry if I am not clear, my english is not good. Thanks

[color="#006400"]/* Moved from "Bug Discussions" to "General Discussion for Yii 1.1.x" */[/color]

Hi kalempir,

So you are using a CGridView in a dialog … How do you supply the initial content of the dialog? And how do you update it?

Could you post your simplified code so that we could understand better what you are doing?

Thank you softark for your reply.

I don’t have source code right now, but the problem as I understand is generic.

Initial content of the dialog (CJuiDialog) is CGridView and thats all. To reproduce the problem just click field header to make sorting. In first dialog openning all will work as we expected. Then close the dialog, and open it again. Now when you click field header, it make two ajax request to server. If you reopen the dialog and make the same actions, you will see that ajax requests is increased. I tested it on official blog example.

But on my project I used yii-booster GridView. In my case it make unlimited ajax requests to server at second dialog openning.

Any idea? It seems a bug on CGridView.

Read this How to avoid multiple Ajax Request

I second Reza m.

If you are loading CGridView via ajax call and you are including the scripts in the ajax response, I think that the problem like you described could easily happen.