Maxx. I took a look at the generated JS-code for grid pager (when grid to be ajax-updated):
jQuery('#assortment-grid').yiiGridView({'ajaxUpdate':['assortment-grid'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'Assortment_page'});
this very js makes to send ajax request for grid paging like this:
http://srv50213.ht-test.ru/app2/index.php?Assortment[itemSearch]=31351134582, BMW 5 SERIES '85-95 ?28/32/34 FORD MONDEO&Assortment_page=5&ajax=assortment-grid&r=assortment/searchtool
in this uri there are magic parameters:
Assortment_page=5
resp. for pagingAssortment[itemSearch]=31351134582...
andAssortment[subgroup]='ДЕТАЛИ КУЗОВА'
- they are responsible for maintaining filtering on server side:if (isset($_GET['realtime-gridAMZ'])) $dataProvider->attributes = $_GET['realtime-gridAMZ'];
ajax=assortment-grid
resp. for indicating ajax call.
Considering these prerequisites, you might try to modify your code to update grid on timer while fetching serialized data. Here you modify some:
function updateAMZGrid() {
$.fn.yiiGridView.update('realtime-gridAMZ', {
data: $(this).serialize()
});
return false;
}
you might want to check what data are passed thru $(this).serialize()
or add smth. like $('#realtime-gridAMZ').serialize()
.
How about you check the $_GET['realtime-gridAMZ_page']
and "copy/paste" it into ajax request:
+ '&realtime-gridAMZ_page=' . $_GET['realtime-gridAMZ_page']
thus you fetch current data for repeated requests. In my case it works well with juiAutoComplete without ajax though:
...
'select'=>'js:function(event, ui) {
$(this).val(ui.item.value);
location.href= "'. $this->createUrl($this->route) . '&Assortment[itemSearch]=" + ui.item.value + $("#uni-form").serialize() ;
}',
Therefore you might try smth. similar to that:
function updateAMZGrid() {
$.fn.yiiGridView.update('realtime-gridAMZ', {
data: $(this).serialize() + $('#realtime-gridAMZ').serialize() + + '&realtime-gridAMZ_page=" . $_GET['realtime-gridAMZ_page'] . "
});
...
return false;
Also check if GET parameters from XHR request are properly fetched on server side:
`if (isset($_GET['realtime-gridAMZ']))
$dataProvider->attributes = $_GET['realtime-gridAMZ'];`
why do you have $dataProvider->attributes = $_GET['realtime-gridAMZ'];
, i usually get GET/POST parameters into model, rather than into DataProvider:
`$model->attributes = $_GET['realtime-gridAMZ'];`
and only after that
`$dataProvider = $model->search();`
Hope, this will help you, feel free to ask any questions if not clear. Do not forget gebugging tools: F12 or Ctrl+Shift+I