Grid setOptions does not render cell template

3 posts, 1 answers
    CORNEL avatar
    44 posts
    Member since:
    Jan 2012

    Posted 06 Sep 2016 Link to this post

    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





  2. Answer
    Alex Hajigeorgieva
    Alex Hajigeorgieva avatar
    625 posts

    Posted 07 Sep 2016 Link to this post

    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:

    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: 

    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
    CORNEL avatar
    44 posts
    Member since:
    Jan 2012

    Posted 08 Sep 2016 in reply to Alex Hajigeorgieva Link to this post

    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.





Back to Top