Difference between #4 and #5 of
Avoiding rendering entire page when using CGridView and CListView via AJAX

Revision #5 has been created by xrx on Jun 19, 2012, 9:16:36 PM with the memo:

CListView tested in meanwhile so I changed title and last sentence
« previous (#4)


Title changed

Avoiding rendering entire page when using CGridView and CListView via AJAX

Category unchanged


Yii version unchanged

Tags unchanged

CGridView, AJAX, render, CListView, Interactions

Content changed

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.
23 0
Viewed: 44 532 times
Version: 1.1
Category: How-tos
Written by: xrx
Last updated by: xrx
Created on: Mar 24, 2011
Last updated: 6 years ago
Update Article


View all history