Hi,
this issue is a followup on this thread!
I am trying to extend the example to persist column state in a cookie. Users can hide/show/resize columns. I thought I could use the same method described in the thread above. Here is my code:
// Add handlers to show and hide events
.Events(events => events.ColumnHide(
"onColumnHideIOrShow"
))
.Events(events => events.ColumnShow(
"onColumnHideIOrShow"
))
// Function is called when a column is hidden or Shown
function
onColumnHideIOrShow(e) {
var
columnlistCookieName =
"GridMarColumns"
;
var
grid = $(
"#GridMar"
).data(
"kendoGrid"
);
var
columns = grid.columns;
var
serializedColumns = kendo.stringify(columns);
$.cookie(columnlistCookieName, serializedColumns);
}
// On load recreate the column list as found in the cookie
$(document).ready(
function
() {
var
columnlistCookieName =
"GridMarColumns"
;
var
serializedColumns = JSON.parse($.cookie(columnlistCookieName));
var
grid = $(
"#GridMar"
).data(
"kendoGrid"
);
if
(serializedColumns) {
grid.columns = serializedColumns;
}
}
When I hide a column from the grid, the column is hidden and I can see that the cookie now has the right information. When I reload the page however, the column is present in the grid, in the columnmenu however, it is no longer there (see image attached). The columns strasse is visible on the gird, but not in the list of columns that I could make visible or invisible.
Thank you for your suggestions on this issue!