I have created some code to save and restore the order of the columns, and it will also work with resizing if I can force it to save the necessary data. It seems that when the "columnReorder" event occurs, the new column order has not yet been saved - therefore, despite the fact that the function of saving and restoring the column works, it is one step back. Does anyone know how to get βnewβ column information or capture an event after a reorder has been made? Here is the part that does the magic ...
var colCook = getCookieColumns();
$("#disputesGrid").kendoGrid({
dataSource: myDataSource,
columns: (colCook != null) ? JSON.parse(colCook) : {default column values},
pageable: {
refresh: true,
pageSizes: [10, 25, 50, 100],
buttonCount: 10,
input: true
},
reorderable: true,
columnReorder: function (e) { saveColumnsCookie(); },
sortable: true,
resizable: true,
selectable: "multiple row"
});
}
function getCookieColumns() {
var cookiesArray = document.cookie.split(';');
for (var i = 0; i < cookiesArray.length; i++) {
var c = cookiesArray[i].trim();
if (c.indexOf("DisputeGridViewColumns=") == 0) return c.substring(23, c.length);
}
return null;
}
function saveColumnsCookie() {
try {
var d = new Date();
d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = "DisputeGridViewColumns=" + kendo.stringify($("#disputesGrid").data("kendoGrid").columns) + "; " + expires;
} catch (x) {
}
}
Note: the new column order does not seem to be in the "e" event, but what is a reasonable place, right?