Hi,
is it possible to get the current Settings of an igGrid table?
Background: I want to store them in a Cookie to Show the table exactly with the same Settings (sorting, column ordering, grouping) as the user has set when he used the table the last time.
Thanks.
Michael
//Suppose this is the Dropdown var QCResult = [ { "ID": "", "Name": "" }, { "ID": "1", "Name": "Pass" }, { "ID": "2", "Name": "Fail" }, ];
//Fomat Method for the dropdown function formatQCResult(val) { var i, category; for (i = 0; i < QCResult.length; i++) { category = QCResult[i]; if (category.ID == val) { val = category.Name; } } return val; }
//This is the IgGrid
$("#gridVari").igGrid({ columns: //JSON.parse($.cookie("Columns")), [ { "headerText": "S.No.", "key": "SerialNo", "dataType": "number", "width": "100px"}, { "headerText": "Sample No.", "key": "SampleNo", "dataType": "number", "width": "150px"}, { "headerText": "Sub Plan Code", "key": "U_O_SUBPLAN_CODE", "dataType": "string", "width": "100px" }, //{ "headerText": "Variable Value Sequence", "key": "U_O_VARI_VALUE_SEQ", "dataType": "string", "width": "250px" }, { "headerText": "Variable Name", "key": "U_O_VARIABLE_NAME", "dataType": "string", "width": "200px" }, { "headerText": "Inspection Type", "key": "U_O_INS_TYPE", "dataType": "string", "width": "100px", "formatter": formatInspectionType}, { "headerText": "Value", "key": "U_O_VARI_MEA_VAL", "dataType": "number", "width": "100px" }, //Bug no. 8143 22-Nov-16 was taking alphanumeric value { "headerText": "Upper Value", "key": "U_O_VARI_UPPER_VAL", "dataType": "number", "width": "100px" }, { "headerText": "Lower Value", "key": "U_O_VARI_LOWER_VAL", "dataType": "number", "width": "100px" }, { "headerText": "Go Result", "key": "U_O_GORESULT", "dataType": "string", "width": "100px", "formatter": formatQCResult}, { "headerText": "NoGo Result", "key": "U_O_NOGORESULT", "dataType": "string", "width": "100px", "formatter": formatQCResult }, { "headerText": "TG Code Used", "key": "U_O_TG_ID_USED", "dataType": "string", "width": "100px", "formatter": formatToolGuage}, { "headerText": "Inspector Code", "key": "U_O_INSPECTOR_ID", "dataType": "string", "width": "100px", "formatter": formatInspectorMaster}, { "headerText": "Observation", "key": "U_O_OBSERVATION", "dataType": "string", "width": "100px", "formatter": formatObservation}, { "headerText": "QC Result", "key": "U_O_QC_RESULT", "dataType": "string", "width": "100px", "formatter": formatQCResult}, { "headerText": "Remarks", "key": "U_O_REMARKS", "dataType": "string", "width": "100px" }, { "headerText": "Line No", "key": "LineId", "dataType": "number", "width": "100px"}, { "headerText": "Lot Is Posted", "key": "LotIsPosted", "dataType": "string", "width": "100px" }, { "headerText": "Line Is Posted", "key": "LineIsPosted", "dataType": "string", "width": "100px" } //{ "headerText": "Test Result", "key": " U_O_TEST_RESULT", "dataType": "string", "width": "100px" } ],
features: [
{ name: "ColumnMoving", columnMovingDialogContainment: "window", columnMoved: function (evt, args) { $.cookie("Columns", JSON.stringify($("#gridVari").igGrid("option", "columns"))); }
]
});
--We are using this cookies for making the state persist till next change by user
Can you send a sample, demonstrating this?
Hey DeyanK,
I am using the same method but the problem is in the grid I have drop-downs, so as we try to reset the columns setting then the text of drop-down is not appearing instead of this it's value is appearing.
For example if I have a drop-down of name like 1=Andrew,2=Liza,3=Peter then it is showing 1/2/3 instead of Andrew/Liza/Peter.
Hey Ashish,
You can extract any of the grid options using the following approach:
$("#grid1").igGrid("option", "columns")
$("#grid1").igGrid("option", "width")
Do this for the properties you want to preserve, store them and use their values when creating the new grid.
Can we store the whole Grid state at Client Side i.e if the user opens the Page for the Next time the Grid State should same as user set last time (Property such as:- Grid's Column order,width etc.)
Thanks & Regards,
Ashish Devade