javascript - Can trigger(“reloadGrid”) works when 'loadonce: true' in jqGrid? -
the jqgrid source file i'm using says @ top it's version jqgrid 4.4.0
, date date 2012-06-14
in wiki page says trigger(“reloadgrid”)
,
reloads grid current settings. means new request send server if datatype xml or json. method should applied already-constructed grid. pay attention method not change header information, means changes colmodel not affected. should use gridunload reload new configuration different colmodel. it's work if loadonce: false !!!
and yes says "it's work if loadonce: false !!!"
and this answer suggest hack that. says,
if use loadonce:true jqgrid change datatype parameters 'local' after first load of data grid. next grid reloading (sorting, paging, filtering) works local. if want refresh grid data server 1 more time should set datatype original value ('json' or 'xml').
so answer solved problem facing. had jqgrid has loadonce:true
. (here care sorting , worked perfectly). had change code bit reload jqgrid new server data. (user can change details , refresh table jqgrid should reload newly aquired data server). unfortunately didn't work until changed loadonce:true
loadonce:false
.
i called reloading this,
$("#tablegrid").setgridparam({url:'myurl'}).trigger('reloadgrid');
now reloading fine. sorting gone :(
and saw answer , change this,
i set loadonce:true
when initializing grid. , called reloading below.
$("#tablegrid").setgridparam({url:'myurl',datatype:'xml'}).trigger('reloadgrid');
after sorting fine , user can reload grid well.
is approach correct ? think solved problem, but ? because documentation says can't reload when loadonce:true
?
first of strictly recommend upgrade jqgrid use version 4.4.0 free jqgrid 4.12.1. free jqgrid fork of jqgrid develop starting end of 2014. see post , link updated part of the answer additional information. should understand jqgrid 4.4.0 retro version. published @ time of jquery 1.4.3 version. time when ie9 latest version of internet explorer, ie6-ie8 used versions. have another time in web development.
it's important understand loadonce: true
, .trigger('reloadgrid')
.
jqgrid support local holding of data inside of javascript objects. 1 can use datatype: "local"
, provides data using data
parameter , work data using local paging, sorting , filtering data. can change values of page size (rownum
), page number (page
) , sorting parameters (sortname
, sortorder
) , reload current displayed page using new options triggering reloadgrid
event. jqgrid sort data , displays requested page. it's important understand .trigger('reloadgrid')
works local data too.
if use datatype:'xml'
loadonce: true
server have return all data. data have sorted requested sortname
, sortorder
options (the parameters sidx
, sord
of request server). jqgrid fills internal data
parameter data. jqgrid displays first page of returned data (based on page size rownum
, page number page
). (after processing loadcomplete
callback) jqgrid changes original value of datatype
("xml"
in case) datatype: "local"
. user can use local paging, sorting , filtering data without communication server. on every sorting, paging , filtering jqgrid uses reloadgrid
event display corresponding page of data.
if need reload data server need restore original value of datatype
parameter , trigger reloadgrid
. example
$("#tablegrid").setgridparam({datatype:'xml'}).trigger('reloadgrid');
if server correctly implemented user see requested page of data , local data refreshed. datatype
changed datatype:'local'
after displaying page.
if use current free jqgrid can use following options
loadonce: true, forceclientsorting: true, navoptions: { reloadgridoptions: { fromserver: true } }
the option forceclientsorting: true
removes server requirement provide sorted data. free jqgrid can sort data returned server. if use navgrid
adds "refresh"/"reload" button. option navoptions: { reloadgridoptions: { fromserver: true } }
changes behavior of button so, data reloaded server if user clicks on button. no manual changing of datatype
not needed.
Comments
Post a Comment