After SetOptions Editable does not get hit

3 posts, 0 answers
  1. Richard
    Richard avatar
    31 posts
    Member since:
    Jan 2017

    Posted 12 Jul 2019 Link to this post

    MVC 5; .Net Core; Visual Studio 2017; Telerik 2019.2.514

    I have a grid that uses SetOptions to load the users saved state.  I am using incell editing.  After using setOptions my events for Editable no longer get hit.  Is there something I have to set manually after this like with the command buttons?

    --Below I reassign the btnEdit event to the command button

    var options = JSON.parse(response.myOptions);
    options.columns[0].command[0].click = btnEdit;
    grid.setOptions(options);

     

    --My cell from grid

    columns.Bound(p => p.ClearedBy).Title(text: "Cleared by").Editable("ClearedByEditable").Lockable(true);

     

    --My Editable Event

    function ClearedByEditable(e) {

    Alert("I am here");

    return false;

    }

  2. Richard
    Richard avatar
    31 posts
    Member since:
    Jan 2017

    Posted 15 Jul 2019 Link to this post

    I got the solution from the link below.  The editable function had to be added back just like the click functions.

    https://www.telerik.com/forums/custom-css-for-conditionally-editable-columns

     

  3. Tsvetomir
    Admin
    Tsvetomir avatar
    757 posts

    Posted 16 Jul 2019 Link to this post

    Hi Richard,

    I am glad to hear that you have managed to resolve the case. And I would like to thank you for sharing the answer with the community. I will go ahead and share the exact lines from that forum post which are relevant to this case:

    "JSON.stringify() cannot serialize function references (e.g. event handlers), so if stringification is used for the retrieved Grid state, all configuration fields, which represent function references, will be lost. You have two options to avoid this limitation: use a custom implementation to serialize JavaScript functions, or add the function references back to the deserialized configuration object before passing it to the setOptions method."


    Kind regards,
    Tsvetomir
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top