jqGrid icon indicating copy to clipboard operation
jqGrid copied to clipboard

jqGridImport & jqGridExport working synergy

Open HASTJI opened this issue 1 year ago • 6 comments

Hello. is there any valid method to save current colums visability for current user in JqGrid? I mean when it was version 4.6 - I made it with : $("#gridframe").jqGrid('jqGridImport',{imptype:"jsonstring", impstring:window.localStorage.getItem("%userid%-gridframe")}); in the beggining, before JqGrid is builded and then created button, which saves all prefs of current grid in local storage: window.localStorage.setItem("%userid%-gridframe",$("#gridframe").jqGrid('jqGridExport',{exptype:'jsonstring'})); But with the latest version it said that jqGridImport is not a function and when I changed it to: $.jgrid.jqGridImport( "gridframe", {imptype:"jsonstring", impstring : window.localStorage.getItem("%userid%-gridframe")}); It started saying that json array is not valid, but all was okay when it was old version.

изображение

изображение

What I'm doing wrong? I already tried to figure out about new syntax, but didn't get any correct results in my researches....

HASTJI avatar May 02 '24 14:05 HASTJI

Hello,

I apologize for delay - for some reason I missed your request.

Try to export with $.jgrid.jqGridExport which is moved to the $.jgrid space too and import it .

Regards

tonytomov avatar Jul 09 '24 10:07 tonytomov

Hm, strange, i think that I'm missing something. Right now I'm using v5.8.5 - 2023-07-19 version. When I'm doing this: window.localStorage.setItem("SavedSearchColums", $.jgrid.jqGridExport('SearchTable',{exptype:'jsonstring'})); it response with: изображение But when I'm trying to do this: $('#SearchTable').jqGridExport('MainSearchTable',{exptype:'jsonstring'}); it displays response, but it....default xml, I guess...? изображение In both ways GridImport saying that it can't read json structure or, if export type set to xml - that xml structure is damaged. I can't understand what I'm doing wrong and how I can Export & Import prefs with new api, if I creating new jqGrid instanse based on tag from jquery: $("#1Search").jqGrid({ caption:"Main Search", datatype: "json", url: $("div#1SearchWrapper").data('cos'), pager: "#1SearchPager", colNames:['.........

Can you please provide some valid working example of the code for latest package version in which colums visability saved and than can be loaded buy calling import & export? Or maybe there is any other, more newer method of managing colums visability on grid load for users?

HASTJI avatar Jul 09 '24 14:07 HASTJI

Hello,

Could you please post your full jqGrid setup, so that we can see what is happen.

tonytomov avatar Jul 09 '24 14:07 tonytomov

Hello,

I totally forgot about these.

Here demo

the methods are


$.jgrid.saveState and $.jgrid.loadState

Docs are here

tonytomov avatar Jul 10 '24 04:07 tonytomov

your full jqGrid setup

https://jsfiddle.net/nambell/gq3j1aL7

Here it is.

Btw already tried SaveState & LoadState - looks pretty much as what I'm looking for, but didn't figure out yet how to load and save only colums visability, without other prefs and data in colums.

HASTJI avatar Jul 10 '24 09:07 HASTJI

Look at the options of the methods there is a way not to save or load the data

tonytomov avatar Jul 10 '24 09:07 tonytomov