This is a migrated thread and some comments may be shown as answers.

[Solved] Persist State Issue - groupHeaderTemplate

2 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AGB
Top achievements
Rank 1
Iron
AGB asked on 29 Jan 2015, 02:34 PM
Hi Guys,

Have just tripped over an issue whereby the persist state is not being reloaded correctly when using a groupHeaderTemplate to render data.

To replicate the issue run the following dojo snippet which is based on the Persist State demo

      http://dojo.telerik.com/IsISa

- Group by the 'Contact Title' column
    
        Group Header displays 'Grouped By: Accounting Manager' as per the grid options

- Save State

- Load State

        The Group Header reverts to 'Contact Title: Accounting Manager'

Looking at the saved JSON object the groupHeaderTemplate is not recorded and therefore gets deleted when the grid state is reloaded.    

Regards
Alan

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 02 Feb 2015, 08:57 AM

Hello Alan,

This is because you are stringing the Grid state which contains functions. Functions are not serialized to string. Quoted from getOptions documentation:

"Notice that when the options object is retrieved and then serialized into a string through JSON.stringify(options), then each field that is a function will be lost. This is limitation of the serialization that the JSON.stringify does."

You can workaround this by making the template string which calls your external global function. Here is updated example - http://dojo.telerik.com/@rusev/EgItI

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
AGB
Top achievements
Rank 1
Iron
answered on 03 Feb 2015, 09:13 AM
Hi Nikolay,

Thanks for the pointer about the functions and the workaround ... I don't know how I missed it when I looked over the docs.

Now that the latest internal build allows for AngularJS filters in the groupHeaderTemplate string the need for additional functions to overcome JSON.stringify limitations are no longer required, but the link to 'super-json' in the docs does look interesting.

Thanks once again
Alan
Tags
Grid
Asked by
AGB
Top achievements
Rank 1
Iron
Answers by
Nikolay Rusev
Telerik team
AGB
Top achievements
Rank 1
Iron
Share this question
or