Avoiding rendering entire page when using CGridView and CListView via AJAX

Comparing #4 with #5

Revision #5 was created by xrx xrx on Jun 19, 2012, 9:16:36 PM.

CListView tested in meanwhile so I changed title and last sentence

Title

Avoiding rendering entire page when using CGridView and CListView via AJAX

Content

[...]
So in index view, put _$this->_getGridViewPost()_ in place where you want your CGridView. In _ _getGridViewPost_ method, create your dataProvider and call _$this->renderPartial()_ of view where you have your CGridView widget.

That's it! On first request, everything works as normal but when you interact with CGridView, filter intercepts request and call only method that is related to CGridView. This also satisfies **Convention Over Confituration** thing. Method with CGridView must have name _getGridView{$ajaxVar} where {$ajaxVar} is widget ID (which is passed by $_GET['ajax']).

Also, in theory, this should work in CListView too but I didn't try it to be honest :)This thing also works for CListView in very similar way.