jQuery UI Widgets › Forums › Grid › Cache Possible in the grid to get the previous state?
Tagged: jqxgrid, load state, save load, save state
This topic contains 5 replies, has 2 voices, and was last updated by Stanislav 8 years, 4 months ago.
-
Author
-
I am using jQXwidgets, something like the following from here.
http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-paging.htm
As seen in
Image #1, I am on the91-100section of the list which is last. Suppose I click on first record which isReginaI will move onto next page in my website. However,
when I click the browser back button, it reloads the page and I am back to the first list with1-10as shown in theimage #2**Questions:**
Is it possible with the browser back button to land on the same list
91-100whereReginaname is listed? Or do I need to add back button and do what to achieve that? Please advise. Thanks**Image #1:**

**Image #2:**

Hello walker1234,
You can use the
save/loadmethods. Binding them to a button, they will save the grid state and after that, when the load is complete, it will load thesavedgrid state. You can see them in our APIs.Best Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/Thanks Stanislav. I saw the JSFiddle there : http://jsfiddle.net/jqwidgets/L4L3P/
I am wondering since I don’t have buttons, how should I proceed. I mean when I click on a row, then I go onto next page, so basically buttons aren’t involved in my case. I have a Single Page application in case you are wondering.
Thanks
Hello walker,
If you want to use the browser’s ‘back’ button, you might be able to, but I cannot help you with that, there should be some information out there.
You could bind to an event when you click on a row, thatsavesthe current grid state. And use a button for the user to return to thatsavedstate.Best Regards,
StanislavHello Stanislav,
Thanks for you input.I understood the functionality mentioned in the JSFiddle example and noticed that
saveandloadStateare happening in one page only.I have the following scenario where I have two pages involved in my single page application. I would like to get your input on the following scenario :The following code is where I have the jqxgrid defined which is similar to the images I mentioned above. The following is the URL of my page of my
Single Page Application containing the grid.https://mywebsite/webapp/#firstpageSince I am not using any button to explicitly save the data, I have defined the
statevariable inside theon clickhandler and then
I tried to save the state as shown below which is capturing the expected paramenter like pagenum, width, height etc.// Handle cell selection $_("#myjqxGrid").on('cellselect', function (event_) { var state = null; // save the current state of jqxGrid. state = $("#myjqxGrid").jqxGrid('savestate'); console.log("State Value:"); console.log(state); // Get the data from the selected row. var rowIndex = event_.args.rowindex; var rowData = $_("#myjqxGrid").jqxGrid('getrowdata', rowIndex); // Get the selected employee's ID and name. var mrn = rowData["mrn"]; var employee_name = rowData["full_name"]; // My logic to display next page goes here which takes user to next page when they click on any cell } }); };After clicking a record, I was directed to another(second) page with the following URL:
https://mywebsite/webapp/#secondpageIn this page, inside my code, I have been able to get the value of the
stateand I tested it with the console log statement:console.log("Retrieved State Value INSIDE secondpage"); console.log(stateValue);Question:
I am wondering if I go ahead and use something like the following in my second page:
if (stateValue) { $("#myjqxGrid").jqxGrid('loadstate', stateValue); } else { $("#myjqxGrid").jqxGrid('loadstate'); }The grid mentioned above
#myjqxGridis not present on this page but on the first page.And first page has URL which is somewhat different
than the second page URL as mentioned above. Do you think it’s possible to go back to the previous page at the same location with the saved state
in this scenario?P.S. I tried using the browser back button from second page to first page but it didn’t work.
Thanks
Hello walker1234,
When you fire the
save state, it saves the whole current state as anobject. You can get this object and load it in another page.Best Regards,
Stanislav -
AuthorPosts
You must be logged in to reply to this topic.