Hi I am wanting to inquire about multiple grids and the method I am using.
So Step 1 I have local memory assigned.
Grid 1 - Works Great
var dataModel = {
dataType: "JSON",
location: "local",
recIndx: "ID",
data: sales.data}
Grid 2 - Works Great
if (window.localStorage.getItem('sales')) {
var sales= JSON.parse(window.localStorage.getItem('sales'));
if (data) {
console.log(data);
obj2.dataModel = { data: sales.data };
}
grid2 = pq.grid("#grid_json", obj2);
}
Now when I make edits to local I call from the main grid to update the JSON stored.
function updateLocale() {
var gridChanges = grid.getChanges({ format: 'byVal' }); //getchanges to push over on locale
var sales= JSON.parse(window.localStorage.getItem('sales')) //obj, keyValue, findKey, findField, newValue
var updateList = gridChanges.updateList;
for (var i = 0, len = updateList.length; i < len; i++) {
for (var property1 in updateList) {
if (/^[C]/.test(property1)) {
replaceAttributebyKey(SCTCollData, "ID", updateList.ID, property1, parseFloat(updateList[property1]));
}
}
}
localStorage.setItem("sales", JSON.stringify(sales)); //put the object back in local
grid.commit({ type: 'add', rows: gridChanges.addList });
grid.commit({ type: 'update', rows: gridChanges.updateList });
grid.commit({ type: 'delete', rows: gridChanges.deleteList });
grid.history({ method: 'reset' });
$("#grid_json").pqGrid("option", "dataModel.data", sales.data );
$("#grid_json").pqGrid("option","refreshDataAndView");
}
I have tested it out by hitting the refresh button on the pager...
when I do $("#grid_json").pqGrid("option", "dataModel.data", sales.data ); and then I hit refresh it goes to zeros. If I take it out of Pivot mode and and back in, my data comes back but as the old data.
when I do $("#grid_json").pqGrid("option", "dataModel.data", sales); it will say the following: c.slice is not a function, l.slice is not a function: If I take it out of Pivot mode and back in, my data comes back but as the old data.
Not sure where I am going wrong.