Hi,
I'm 100% sure I've found a bug that occurs when trying to load a state into the kendo Filter component.
I've tried this on the example of the official documentation below ("Loading Settings on Demand")
https://docs.telerik.com/kendo-ui/controls/data-management/filter/state#loading-settings-on-demand
Here are some reproduction steps:
1. Click Add expression
2. Add Cost - Is equal to - 25
3. Click Save
4. Click any of the 2 close icons
5. Click Load (This should load in the filter of the cost being 25)
6. Once again, click any of the 2 close icons.
7. Click Save
8. Click Load (This should load all the results since we removed the filters and saved that state.)
9. As you can see, it once again loaded the filter instead of loading in the empty filter object.
Please fix this :)
Kind regards
Hello Karel,
Thank you for reporting this problem to us. It is actually a problem in the demo not in the component. Initially when no filter is applied the expression option is null. After deleting the cost filter the expression is an object. Later when someone calls set options we deep extend the objects and that is why the old cost filter is persisted. This is a pattern we follow through the entire suite. The problem can be resolved by saving a falsy value in the local storage if no filters are present. In other words the save logic can be modified as follows.
function saveState(e) {
var expression = getFilter().getOptions().expression;
localStorage["myFilterSettings"] = expression.filters ? JSON.stringify(expression) : "";
// You can store and restore all options not just the expression.
}
We will update our documentation sample as soon as possible to integrate this approach.
Regards,
Angel Petrov
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.