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

Grid setOptions does not render cell template

2 Answers 634 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 06 Sep 2016, 08:23 AM

Hi Guys,

 

I'm exploring the kendo grid persisting of state feature, whereby on a user column re-ordering i would save state and re-load it on next page load, so that basically a user can choose to customize the order of columns.

All fine and dandy till here, except the grid has cell javascript template defined as kendo javascript blocks, and when calling setOptions method the grid state is loaded but the cell templates are not applied.

Tried a few options but could not make this thing work out of the box. Would like to know if this is a known limitation or bug??

* Here is sample code of what im trying to acomplish  http://dojo.telerik.com/ifoWA/5

Cheers!

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 07 Sep 2016, 11:31 AM
Hi Cornel,

The template of the Kendo UI Grid column is lost because it is a function. This is a known limitation of the JSON.stringify() method:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-setOptions

In addition to the solutions described by the provided documentation reference above, you may choose to keep the column template inline as a string and the JSON.stringify limitation will not affect it.

For your convenience, I have updated the provided Dojo snippet at:

http://dojo.telerik.com/iXafA 

Regards,
Alex
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
0
IT
Top achievements
Rank 1
answered on 08 Sep 2016, 07:59 AM

Hi Alex,

Many thanks for the informative reply!

The option to keep the column template is not possible in this case as there is extensive logic in the actual template code block.

The custom JSON parser looks an interesting solution to overcome native JSON.stringify limitations. One other way i was able to achieve the requirements is by using the grid reorderColumn method to re-arrange columns order on page load.

 

Cheers!

 

 

Tags
Grid
Asked by
IT
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
IT
Top achievements
Rank 1
Share this question
or