when load state -> custom editor is not rendered as expected

1 Answer 45 Views
Filter
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Aleksandr asked on 14 Sep 2023, 12:13 AM

when load 

 

 

expected

 

 

Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
commented on 14 Sep 2023, 12:32 AM

change event is not fired too
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
commented on 14 Sep 2023, 02:48 PM

this is because you lose editor info deserializing state, basically, you save to state all options, but just what can be changed, wired approach
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
commented on 14 Sep 2023, 02:51 PM


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

Sort by
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.

Let me know if you have any questions.

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
commented on 18 Sep 2023, 11:59 AM

in general i do not understand why you serialize predefined part rather then just possible expression? just expressikn can be changed 
Martin
Telerik team
commented on 21 Sep 2023, 07:43 AM

Hello Aleksandr,

I am not sure I understand the question. That is how the JSON.stringify method works. Kindly let me know what I am missing.

Tags
Filter
Asked by
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Answers by
Martin
Telerik team
Share this question
or