I am using two jqgrids in one page. second grid i used loadonce: true
since i need column sort in the second grid. i need to reload both grids after a server post back. (need to show updated value in the second grid). first grid reload fine since it won't use the loadonce
attribute. my question is can we use loadonce
attribute and reloadGrid
together? ( by setting loadonce
attribute dynamically to the grid) or else do i need to go for a server side sorting in this case? please advice. Thanks in advance.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
If you use
loadonce:true
jqGrid change thedatatype
parameters to 'local' after the first load of data from the grid. All next grid reloading (sorting, paging, filtering) works local. If you want refresh the grid data from the server one more time you should setdatatype
to its original value ('json' or 'xml'). For example:UPDATED: Free jqGrid supports
fromServer: true
option ofreloadGrid
starting with the first release (starting with version 4.8). So one can use the code liketo do the same as above. The main advantage: such code works fine with any initial value of
datatype
("json"
,"jsonp"
,"xml"
and so on). Free jqGrid saves original value ofdatatype
inside of internaldataTypeOrg
before changing it to"local"
.One more helpful option of free jqGrid is the parameter
reloadGridOptions
ofnavGrid
, which allows to specify default options ofreloadGrid
. Thus one can use for exampleoptions of jqGrid, which set defaults for
navGrid
additionally. As the result the click on "Reload" button of navigator bar will reload the grid from the server instead of local reloading.Nice was trying for last one week , solution is perfect use
to reload the data using
loadonce:false
Will remove the structure and then your code can rebuild the grid with the data from the next server call-back.
Just to say, for me, the following line wasn't enough, to refresh the data in my
loadonce:true
jqGrid:After calling that line, I tried to call my code which loaded my JSON data and populated the
jqGrid
with it, but it didn't refresh the rows in my grid.My solution was to forcibly unload the jqGrid, and then call my function to recreate it.
Perhaps I was just unlucky.
Btw, when I get a chance, I'll document how I wrote a generic JavaScript function to add two buttons to any jqGrid, one to refresh the (loadonce) data, and a second button to export the jqGrid data into a real Excel file, using my library:
Export jqGrid to an Excel file
I like reuseable code !