if (options.fields) {
options.fields.forEach((element) => {
switch (element.name) {
case'StateId':
element.editorTemplate = stateEditor;
break;
case'AgencyId':
element.editorTemplate = agencyEditor;
break;
default:
console.log(`Sorry, we are out of ${expr}.`);
}
});
}
externalFilter.setOptions(options);
will restore, but again, seems you did it in the wrong way, just save to state what can be changed & restore it the same way, fields are not going to be changed, they are predefined
1 Answer, 1 is accepted
0
Martin
Telerik team
answered on 18 Sep 2023, 11:52 AM
Hello, Aleksandr,
This behavior is expected as this is how the JSON.stringify method works. As stated in the setOptions article, JSON.stringify() cannot serialize function references (e.g. event handlers). A possible approach to handle the scenario is demonstrated in this How-To article. Even though it is about the Grid, the principle is the same.
if (options.fields) { options.fields.forEach((element) => { switch (element.name) { case 'StateId': element.editorTemplate = stateEditor; break; case 'AgencyId': element.editorTemplate = agencyEditor; break; default: console.log(`Sorry, we are out of ${expr}.`); } }); } externalFilter.setOptions(options);