Forum


00:15

24/08/2011

I'v been looking all over the place but can't find any solution. I want to store the grid settings (column order, filters, sorting,...) in a database as 'views'. So the user can click a button and the saved views are listed. If he selects one, the grid should change to the settings stored in that 'view'. I wrote the extension to the grid, and storing them using the export function works.
However importing the exported grid fails, as my data is lost.
I tried this simple piece of code below and i would expect the grid would remain the same, however i am left with a completly blank table tag.
var savedata=grid.jqGrid('jqGridExport',{exptype:"jsonstring"});
grid.jqGrid('GridUnload').jqGrid('jqGridImport',{imptype:"jsonstring", impstring:savedata});
I'm using 4.1.2. My grid loads its data from a json script, so no local data. I would expect the gridimport to trigger a reload, but this doesn't happen. I tried calling all sorts of functions (clearGridData, setting the this.grid to null,....) , but none helps. looked at jqgridstate, but that saves the state in a cookie or jstorage, i want to save it in my own database table.
18:23

16/09/2011

I suspect you have a similar problem to what I do(see: http://www.trirand.com/blog/?p.....38;ret=all). Well first of all, I'm not sure import works like you are trying to do. I tried to something similar. On page entry I wanted to check to see if the user had a saved configuration so I did an ajax call which returns the json of the grid config if there was one. I then tried to load data like you're doing but it didn't work for me at all.
To see if it's even running correctly for you what you can do is this
grid.jqGrid('GridUnload').jqGrid('jqGridImport',{imptype:"jsonstring", impstring:savedata,importComplete: function() {alert('something');}});
That importComplete runs when the grid loads. In my case it would never run without having the mtype and impurl in it. So, i just made a second call to my controller. After I fixed that I noticed some issues with export. I'm not sure why but when I export my grid it gives way more stuff in the json than I supply and that causes the import to break. If I manually roll my own json file I was able to make it work. By that I mean do something like this
'{"grid":{' +
'"url": "' + $('#grid').getGridParam('url') + '", ' +
...etc
Most Users Ever Online: 715
Currently Online:
56 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66