I have a jqgrid with data loading from an xml stream (handled by django 1.1.1):
jQuery(document).ready(function(){
jQuery(\"#list\").jqGrid({
url:\'/do
It seems to me you should replace
postData:{
site:1,
date_start:document.getElementById('datepicker_start').value,
date_end:document.getElementById('datepicker_end').value
},
with
postData:{
site:1,
date_start: function() { return document.getElementById('datepicker_start').value; },
date_end: function() { return document.getElementById('datepicker_end').value;}
},
UPDATED:
In your current solution the value of postData
are calculated one time as you create jqGrid. In the postData
with functions jqGrid forward postData
to jQuery.ajax
and during every jQuery.ajax
(after $("#list").trigger("reloadGrid");
) the values from datepicker will be read at the moment of jQuery.ajax
call.
Unloading the grid before making a new request seem to bust the cache for me. Simple use GridUnload() method before the grid fetching code.
$("#list").GridUnload();
jQuery("#list").jqGrid({
...
ajaxGridOptions: {cache: false}
});
It looks like a browser caching issue. By default, IE will cache the results of a GET request. So even if you make the same request multiple times from the same browser instance, if it is for the same URL it will always use the cached version (IE, data from the first request).
Internally, jqGrid uses jQuery.ajax to retrieve data. You can instruct jqGrid to pass additional options to the ajax request via the option ajaxGridOptions
. So just tell it to not cache results and you should be good to go:
jQuery("#list").jqGrid({
...
ajaxGridOptions: {cache: false}
});
Alternatively:
If the first approach does not work with django due to the construction of the GET URL (since jQuery will use the ?
construction), another possible option is to completely reload the grid. To do so:
GridUnload
to unload the grid,.jqGrid
again to reinitialize the entire gridurl
option to guarantee the URL is unique, otherwise it will just be cached again. Obviously this is not as nice of a solution, but it would work.