oceatoon
(Oceatoon)
December 21, 2011, 6:58am
1
Hi
I’m Loading a CGridView by Ajax in Jquery Tabs
so the content is filled by ajax
but I think this is the reason why the ajax pagination features don’t work
probably the ajax features aren’t intialised ?
anyone have a solution ?
when I test the same gridview in normally loaded page it works fine
a similar example would be calling a cgridview inside a dialog popin
I put this into a ajax called dialog
and pagination or search wont work with ajax links
it’s always a page reload
<?php
$model=new Comments('search');
$model->unsetAttributes();
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'comments-grid',
'dataProvider' => $model->search(),
'filter'=>$model,
'filterCssClass'=>'gridFilterInput',
'rowCssClass' => array('w','g'),
'itemsCssClass'=>'main-table',
'columns'=>array(
'id',
'userid',
'type',
'comment',
'created',
),
)); ?>
any hint would be greatly appreciated
Cheers
oceatoon
(Oceatoon)
December 23, 2011, 7:15am
2
anyone around ?
is it christmas holidays at Yii !!
Merry Yiistmas to all
I’d just like to know is it my implementation that is is wrong and someone
has this working fine
or is it just a cgridview limitation ?
Thanks
kokomo
(Mwerlberger85)
December 23, 2011, 7:44am
3
I’m not sure but try setting the fourth parameter of renderPartial to true in your controller. If you have problems with AJAX features loaded by an ajax request itself, it is often the fourth parameter which makes it working.
Merry Yiistmas
oceatoon
(Oceatoon)
December 23, 2011, 1:05pm
4
Thx Kokomo
That was my Yiistmas gift of the day !!
cheers
Tibor
oceatoon
(Oceatoon)
January 11, 2012, 9:34am
5
Hi All
I added the fourth param of rendePartial to true
but in time I noticed some strange behaviors in the site
and I noticed this , renews a GET of JQuery
but seems to be breaking all the previously loaded libraries ?
can anyone confirm this ?
or explain what exactly is done when this 4th param is at true ?
I tried adding the scripts manuely (without the register Script) but then the build in features don’t work anymore
I’d be really glad to have someone elses insight on this
sysprog
(Sysprog)
January 20, 2012, 11:57am
6
Hi.
You just need also stop the jquery initialization twice.
Something like this:
Yii::app()->getClientScript()
->scriptMap = array(
'jquery.js' => false,
'jquery-ui.min.js' => false
);
oceatoon
(Oceatoon)
February 1, 2012, 7:39am
7
Thanks Sysprog
but where would you put this
I tried disabling the script in the Cgrids registerScript
but that didn’t solve it
I’d like to try your way but can’t see how to implement it ?
if anyone has an idea on how to solve this
I’m getting desperate
sysprog
(Sysprog)
February 1, 2012, 9:21am
8
Thanks Sysprog
but where would you put this
I tried disabling the script in the Cgrids registerScript
but that didn’t solve it
I’d like to try your way but can’t see how to implement it ?
if anyone has an idea on how to solve this
I’m getting desperate
You should put this into the view
that you render with the renderPartial before any jquery initializations called
oceatoon
(Oceatoon)
February 1, 2012, 9:28am
9
I tried that but had no impact
The RenderPArtial view is loaded on demand after initial page load
but one that demand when the view is loaded
everything goes well
but when I try to access something using the initial feature libraries
these don’t work anymore
so the impact is definitly coming from the renderPartial load
but It’s a bit hard to debug and to know what is causing the problem
sysprog
(Sysprog)
February 6, 2012, 6:45pm
10
I tried that but had no impact
The RenderPArtial view is loaded on demand after initial page load
but one that demand when the view is loaded
everything goes well
but when I try to access something using the initial feature libraries
these don’t work anymore
so the impact is definitly coming from the renderPartial load
but It’s a bit hard to debug and to know what is causing the problem
This is usual problem when your libraries initialized twice
You need to render the main page with the all needed libraries first
You can call the renderPartial (…, …, false, true ) view with the forth param is on
(all libraries of the view would be loaded)
You could stop the scripts initialized twice - like jquery.js or any other you need. To do this use the script above.
If any problems, try the Firebug (http://getfirebug.com/ ) first to see the scripts loading with the page, then, please, put the code of the main view here.
oceatoon
(Oceatoon)
February 7, 2012, 5:26pm
11
The impacting issue behind my problem is the way registerScript works
I’m not sure I’m in full control with it yet, nore how it is supposed to behave
in ajax contexts, where libs are often loaded on demand.
In this use case while desperatly trying to gain control over loading libs (when having a cgrid in a an ajax called tab)
I’m trying to only do the init part
but how to do the equivelant manuelly ?
$cs->registerScript(__CLASS__.'#'.$id,"$('#$id').yiiGridView($options);");
but this keeps loading (and overloading) jquery.js again
eventhough it is allready loaded initialy
Im loading bbq and ygridview JS files manuelly (without registerScript)
but I’m stuck at trying to initialise the JS feature behind a Cgrid
could someone please give me a light on how this works ?
oceatoon
(Oceatoon)
February 8, 2012, 5:15am
12
the solution was out there under the carpet
Thanks for great sharing Community
http://www.yiiframework.com/forum/index.php?/topic/10427-ajax-clientscript/
it seemed to be a clientscript bug , so I confrim it is still around ,
and I 'm quite surprised Yii didn’t integrate zaccarias solution
I prefered doing all the JS manuelly
1 - got the cgridview working in my ajax content
2 - noticed pagination and other filter ajax features were broken
3 - overloaded CgridView with a CgridViewBis where I change the registerClientScript by emptying it
4 - I now add into my ajax content the two needed scrtipt tags (jquery.yiigridview,jquery.ba-bbq) and had copied the init generated code from step 2
// initializing CGrid's ajax features
$('#<?php echo $gridId?>').yiiGridView({'ajaxUpdate':['1','<?php echo $gridId?>'], 'ajaxVar':'ajax', 'pagerClass':'pager', 'loadingClass':'grid-view-loading', 'filterClass':'filters', 'tableClass':'round-table', 'selectableRows':1, 'pageVar':'Meetings_page'});