jQuery UI Widgets › Forums › Grid › Grid State
This topic contains 5 replies, has 3 voices, and was last updated by sjkcwatson 9 years, 10 months ago.
-
AuthorGrid State Posts
-
Hello,
I am trying to getState from one grid and load its state to another. like:
var gridState = gridObj.getState();
$(“#printGrid”).jqxGrid(‘loadstate’, gridState);
Is there any thing which I am missing.Thanks
RajaHi Raja,
The state of a Grid is unique to the Grid. You can’t apply it to another Grid.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comIf that is the case, then how are we doing it in the demo provided for state maintenance.
In this demo, we change the sort and apply some filters. Then press save state button to save the state.
Now we refresh the page. Navigate to same page and then press load state to restore the state of the grid we saved.
This works. How? Because we refreshed the page, isn’t this equal to saving state in one grid and loading the state to another grid?
Thanks
RajaHi Raja,
This is the same Grid. You save and load the state of the same Grid.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comRajamalik – were you ever able to get this situation to work? I am trying to do the same thing – I need to exit the page when editing a grid row and would like to “save the state” to a database entry upon leaving and then when I come back to the page after editing (which reloads the page with a new grid as you described) load the saved state from the database so that the grid is back to the same position and condition it was before leaving to edit. I have everything working, except that the loadstate does not work when the page has been loaded again vs refreshreshed which would make sense if it is seeing it as a different gird as Peter says. Just wondering if you found another work around that might work for my situation as well. Thanks!
Nevermind – I got it to work. I’ll post my code in case anyone else is trying something similar. I will say, that the grid I am loading it to is identical to the one that it is saved from.
$("#jqxgrid").jqxGrid({ theme: 'OriasBlue', width: '100%', height: 550, source: gridDataAdapter, sortable: true, pageable: true, autoheight: true, columnsresize: true, pagesize: 20, pagesizeoptions: ['10', '20', '30','50','100','250','500','1000'], pagermode: 'default', localization: getLocalization(), showfilterrow: true, filterable: true, altrows: true, editable: false, enablekeyboarddelete: false, showrowdetailscolumn: true, selectionmode: 'singlerow', rowdetails: true, autoloadstate: false, autosavestate: false, rowdetailstemplate: { rowdetails: "<div style='margin: 10px;'><ul style='margin-left: 30px;'><li class='title'></li><li class='capaNotesTitle'></li></ul><div class='capaDetails'></div><div class='capaNotes'></div></div>", rowdetailsheight: 350 }, initrowdetails: initrowdetails, columns: [ { text: '', datafield: 'PriorityImagePath', width: '2%', cellsrenderer: imagerenderer }, { text: vIDTitle, dataField: 'CAPAID', width: '6%', cellsalign: 'left', align: 'left' }, { text: vDescriptionTitle, dataField: 'ShortCADesc', width: '32%', cellsalign: 'left', align: 'left' }, { text: vDateAddedTitle, dataField: 'DateAdded', filtertype: 'date', width: '12%', cellsalign: 'right', cellsformat: 'd' }, { text: vDueDateTitle, dataField: 'DueDate', filtertype: 'date', width:'12%', cellsalign: 'right', cellsformat: 'd' }, { text: vResponsibleTitle, dataField: 'RespPersonShortName', width: '12%', cellsalign: 'left', align: 'left' }, { text: vModuleTitle, dataField: 'CAModule', filtertype: 'list', filteritems: [vInspection, vIncident, vHazard, vMOC, vRRS, vNCMR, vDiscrete], width: '10%', cellsalign: 'left', align: 'left' }, { text: vSiteTitle, dataField: 'SiteDesc', width: '14%', cellsalign: 'left', align: 'left' } ], ready: function () { var MyResult; $.ajax({ async: false, type: "post", contentType: "application/json; charset=utf-8", dataType: "json", data: JSON.stringify({ EmpID: cs_EmpID }), url: "WebServices/OriasWcfService.svc/GetGridState", success: function (result) { alert("OC S=" + result.d); MyResult = result.d; if (MyResult != '') { var thisstate = JSON.parse(MyResult); $("#jqxgrid").jqxGrid('loadstate', thisstate); } }, error: function (xhr, status, error) { } }); } });
` $(“#saveStateToDB”).on(‘click’, function () {
var myresult = ClearGridState(cs_EmpID);
var state = $(‘#jqxgrid’).jqxGrid(‘getstate’);
theSavedState = JSON.stringify(state);
alert(theSavedState);
myresult = SetGridState(cs_EmpID,theSavedState);
});
//`The webservice function returns a string containing the state from the database if one was saved.
-
AuthorPosts
You must be logged in to reply to this topic.