I have a page with 4 autocomplete fields and one text field all in a row. The fields are used to apply filters to a grid. When I enter something in the plain text field, and apply the filters to the grid, everything works fine. The filters are applied and the data in the grid is reduced. When I then click a link in the grid to view the detail page for the record, and then click the back button to get back to the grid, the value that was in the text field is displayed in the first autocomplete box for some reason.
I save the grid state to localStorage using the dataBound event of the grid:
$('.grid').kendoGrid({
...
dataBound: this.saveGridState
...
Where this.saveGridState is:
var grid = $('.grid').data('kendoGrid');
var dataSource = grid.dataSource;
var state = JSON.stringify({
page: dataSource.page(),
pageSize: dataSource.pageSize(),
sort: dataSource.sort(),
group: dataSource.group(),
filter: dataSource.filter()
});
localStorage.setItem('gridState', state);
I load the state when the document is ready using:
$(document).ready(function(){
var state = JSON.parse(localStorage.getItem('gridState'));
var grid = $('.grid').data('kendoGrid');
if(state && Object.keys(state).length > 0) {
if(state.filter && state.filter.filters) {
ctx.showFiltersInInputs(state.filter.filters);
}
grid.dataSource.query(state);
}
else {
grid.dataSource.read();
}
});
I initially thought that the function I use to put the filters back into their inputs was mistakenly putting the data in the wrong field. However, if i set a breakpoint in chrome before any of the kendo related javascript, I still see the value in the wrong field. It appears the autocomplete is somehow persisting the value in the plain text field when I browse to the detail page and sticking it in the first autocomplete. Seems really weird. Any idea what this could be?
Thanks,
Troy
I save the grid state to localStorage using the dataBound event of the grid:
$('.grid').kendoGrid({
...
dataBound: this.saveGridState
...
Where this.saveGridState is:
var grid = $('.grid').data('kendoGrid');
var dataSource = grid.dataSource;
var state = JSON.stringify({
page: dataSource.page(),
pageSize: dataSource.pageSize(),
sort: dataSource.sort(),
group: dataSource.group(),
filter: dataSource.filter()
});
localStorage.setItem('gridState', state);
I load the state when the document is ready using:
$(document).ready(function(){
var state = JSON.parse(localStorage.getItem('gridState'));
var grid = $('.grid').data('kendoGrid');
if(state && Object.keys(state).length > 0) {
if(state.filter && state.filter.filters) {
ctx.showFiltersInInputs(state.filter.filters);
}
grid.dataSource.query(state);
}
else {
grid.dataSource.read();
}
});
I initially thought that the function I use to put the filters back into their inputs was mistakenly putting the data in the wrong field. However, if i set a breakpoint in chrome before any of the kendo related javascript, I still see the value in the wrong field. It appears the autocomplete is somehow persisting the value in the plain text field when I browse to the detail page and sticking it in the first autocomplete. Seems really weird. Any idea what this could be?
Thanks,
Troy