Take this Dojo: https://dojo.telerik.com/iCECeXeC
1. Press 'Run'
2. Remove the filter for Contact Title
3. Press 'Save State'
4. Reload page (F5)
5. Press 'Run'
6. Press 'Load State'
Result: The filter for Contact Title is not removed.
On the other hand if I do the following:
1. Press 'Run'
2. Change the filter for Contact Title to 'Sales Representative'
3. Press 'Save State'
4. Reload page (F5)
5. Press 'Run'
6. Press 'Load State'
Result: The filter for Contact Title is changed correctly to 'Sales Representative'
Why is the first example not working? Is this intended behaviour or a bug? Is there a workaround?
Kind regards.
Hello again, Stefan,
I have logged the described issue as a bug into the Feedback Portal and you could follow the report here, as well as in the Kendo UI Core Github repository if you prefer here.
I would like to thank you for helping us to improve, so I have granted your account with Telerik points.
Thank you!
Regards, Silviya Progress Telerik
Hello, Stefan,
Thank you for the described example.
In the first case, we are receiving an empty object. This means that on deep copying there are no properties to be shared, so the current object will stay the original one.
At the moment as a workaround, you could check if the object is empty - if true set the DataSource filter object with an empty filter array. This way it will not be replaced, as it is no longer empty object.
$("#load").click(function (e) {
e.preventDefault();
var options = localStorage["kendo-grid-options"];
if (options) {
var parsedOptions = JSON.parse(options);
if(!Object.keys(parsedOptions.dataSource.filter).length){
parsedOptions.dataSource.filter = { filters:[], logic:"and"};
}
grid.setOptions(parsedOptions);
}
});
We are going to discuss the reported case with the team. I will keep the thread updated.
Thank you
Kind Regards, Silviya Stoyanova Progress Telerik