jQuery UI Widgets › Forums › Grid › saving state on rowselect not sending selectedrowindex in json
Tagged: grid, savestate, selectedrowindex
This topic contains 1 reply, has 1 voice, and was last updated by alberto.reina 8 years, 9 months ago.
-
Author
-
Hello,
I am trying to save the state of my grid whenever a select a row, I have tried two approaches but none of them seems to work.
When I do this:
$(“#” + gridName + “jqxgrid”).bind(‘rowclick’, function (event) {
var gridState = JSON.stringify($(“#” + gridName + “jqxgrid”).jqxGrid(‘savestate’));
SaveGridStateDB(gridName, gridState, GridUserID, GridServiceURL, GridProjectName);});
The result is that it sends in my stringify stuff this : \”],\”selectedrowindexes\”:[0],\”selectedrowindex\”:0,\”, but that zero correspond to the previous click, not the actual one. I am assuming the click event happens before rowselect.
The other approach is when I do this:
$(“#” + gridName + “jqxgrid”).bind(‘rowselect’, function (event) {
var gridState = JSON.stringify($(“#” + gridName + “jqxgrid”).jqxGrid(‘savestate’));
SaveGridStateDB(gridName, gridState, GridUserID, GridServiceURL, GridProjectName);
});The result is that it sends in my stringify stuff this: \”],\”selectedrowindexes\”:[],\”selectedrowindex\”:-1,\”, even though I am selecting a row. So I am assuming there should be another method like “afterrowselected” or “rowselected” but I can’t see that in the API.
Can you help me out?
Regards.
What I did was this, (I think it’s a workaround though):
$(“#” + gridName + “jqxgrid”).bind(‘rowselect’, function (event) {
var args = event.args;
var selectedrowindexes = [];var gridStateJSON = $(“#” + gridName + “jqxgrid”).jqxGrid(‘savestate’);
selectedrowindexes.push(args.rowindex);
gridStateJSON[‘selectedrowindexes’] = selectedrowindexes;gridStateJSON[‘selectedrowindex’] = args.rowindex;
var gridState = JSON.stringify(gridStateJSON);
SaveGridStateDB(gridName, gridState, GridUserID, GridServiceURL, GridProjectName);
}); -
AuthorPosts
You must be logged in to reply to this topic.