jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Question(s) about Grid
Tagged: groups save state
This topic contains 6 replies, has 4 voices, and was last updated by stephan 11 years, 9 months ago.
-
AuthorQuestion(s) about Grid Posts
-
Sent this to jqWidget Sales, but never heard back so hoping a knowledgeable member can help: Been looking for a jQuery component that mimicks a reporting module we developed for Windows-based programs. We’ve done the demos and it seems very impressive; without spending a lot of time test-coding, etc., we have what I hope are some basic questions (mostly about persistance options) on jqxGrid before purchase:
1. Can GridState be saved out to webservice and later retrieved / implemented?
2. Does GridState save with:
a. Grouping?
b. Expand / Collapse selections?
c. Columns Show/Hide?
3. Its it possible to allow user to change Pinned Column
4. Does Export download with:
a. Grouping?
b. Columns Shown/Hidden (i.e., not downloaded)?
d. Pinned columns (in Excel)(not that important)?The ability to save / retrieve Gridstate is critical for us.
Thanks in advance for any guidance on these items!
I believe most of this is possible. I can tell you that it is possible to save and load the grid state to an external datasource. In my app i save the state of the grid to a mysql db when the user logs off, then reload it when they sign back in. When you save the state of the grid you can see that most of the items you mentioned are indeed saved (i.e. if you parse the JSON object returned by the save state method you can see that things like hidden, applied filters, order, size…..and on and on ARE ALL SAVED). These questions are easily answered by looking at the JSON object returned by the save state, so make your grid however you want to, then take a look a the state object and verify that all the attributes you want are present.
Hi TMC,
-You can take the state’s object by using the same approach like the Save/Load State Online sample.
– Grouping’s state is not saved.
– Pinned columns are set during the Grid’s initialization.
– Export does not support Grouping. The Grid is exported as Flat table.
– There is a setting to set whether the hidden columns should be exported or not. That setting is part of the parameters list of the “exportdata” method – see the API for more information about that method.Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks to both of you for the replies. I’ve looked at the API – it *looks* like I can retrieve current group array (for save) as well add grouping (from saved data) using the groups array – is that correct?
As example, if I update the groups array after loading a GridState, will it update the UI with the new/changed group(s)? I know I could work up a test on this, but its so critical to our needs that its not worth doing if not possible.
Thanks again!
Hi TMC,
The Grouping Columns array will be reloaded after loading the state, but the Expand/Collapse states of the Groups would not be.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter – I’ve gone ahead and played with it a bit (turned out to be pretty easy – nice work in the API / Demos!). Dynamically saving / loading groups as separate array is no big deal; weird thing you obviously know about: the state at save shows the group array but does not save into the variable and/or load back. So just saves as separate array works (see sample Save / Load state demo mods for anyone else who might benefit)
var state = null;
var stategroups=[];$(“#saveState”).click(function () {
// save the current state of jqxGrid.
state = $(“#jqxgrid”).jqxGrid(‘savestate’);
for (var i = 0; i < state.groups.length; i++) {
stategroups.push(state.groups[i]);
}
})$("#loadState").click(function () {
// load the Grid's state.
if (state) {
$("#jqxgrid").jqxGrid('loadstate', state);
// Reset Groups Array
$("#jqxgrid").jqxGrid('groups').length = 0;
// Add/Push save groups into Grid
for (var i = 0; i < stategroups.length; i++) {
$("#jqxgrid").jqxGrid('groups').push(stategroups[i])
}
}
else {
$("#jqxgrid").jqxGrid('loadstate');
}
});Hi,
Saving and loading of grid state is something that is seriously bothering me right now, which is why I’d like to offer some advice here.
Loading a grid from a state saved to a external data source is a tricky process. If the saved state no longer matches your actual grid columns very weird errors or misb ehaviour will results. For me ths can happen quite often because I auto-generate grid column structure from database tables. Now if the database table used as basis for creating the grid gains (or looses) a column strange things will result.
The grid state data object is very all inclusive and grid API only allows loading it as is, ie. with all that is has been saved. Partial state saving or loading is not supported by the API. If you do not want to restore things like filtering or grid row(s) selection state or grid column header texts you or current shown page of the grid (etc) will have to manually tinker with the grid state data object. For me this is a another serious issue, as I only want to restore part of the saved data.
An externally saved grid state can not used for creating a grid. This causes increased creation time and grid content flickering. First you create the grid which makes it show up in default state, then you load the state which you saved externally into the grid which makes it update based on the state. I already have customer complaints about this: the want faster grid load times and dfinitely no content flickering.
Also the last time I investigated grid state loading there was a weird behaviour that to me is a (sortof) bug: creating a grid and then loading the state does not (always) restore column sizes, which is one of the most important properties that I must restore. Apparently creating a grid with automatic column size mode prevents column size explizitly set by a user (by dragging) from being loaded. My conclusion: based on whether I have a saved state or not I must create the grid in 2 different ways.
I am writing this down because that is exactly what I am working on right now. Basically I see two options:
1) after getting the grid state from the grid you can modify it before saving it to an external data source, to ensure that when you load the state you get exactly (and only) what you want
2) after getting the grid state from the grid save it to the external data source thus not loosing any information, but instead of using grid API to load the state into the grid create your own logic for restoring those party of the state that you application needs
I have decided to implement solution 2) and combine it with grid creation. In other words: I shall write a function to derive the parameters for creating a grid from a given grid state object, if such is available. I am not particularly hapy about this, as my code will become highly dependant on grid internal details, but it seems to be the only option allowing me to circumvent all the shortcomings listed above.
Regards,
Stephan -
AuthorPosts
You must be logged in to reply to this topic.