"e.model" not back to the orginal value in ListView Cancel Event

9 posts, 1 answers
  1. Zhonghai
    Zhonghai avatar
    20 posts
    Member since:
    Mar 2014

    Posted 07 Jul 2014 Link to this post

    Hi there,

    don't know if I miss anything, but my case is that when I am trying to get the current cancelled edit item, the values in the e.model is not restored back to the orignial values before edit.

    Using "console.log(e.model)", it looks like the model is restored to the original one, but if you write out a value, e.g. "console.log(e.model.comment)", the "comment" value is not retored back to the orginial value, but the edited value before cancelling. Please see the attached screen shot for details.

    Need urgent help from your guys, anyone could help?

    Regards

    Zhonghai
  2. Zhonghai
    Zhonghai avatar
    20 posts
    Member since:
    Mar 2014

    Posted 07 Jul 2014 in reply to Zhonghai Link to this post

    Hi there,

    tried with a demo here, seems that in the cancel event if's only possible to get the edited value instead of the original values. E.g. in the following example, if you edit the product name "Chai" to "foo", after click on the cancel button, i'd like to have the "Chai" back in the e.model.ProductName, but it's not, it's the value "foo".

    here is a "Kendo UI Dojo" code sample.
  3. Kendo UI is VS 2017 Ready
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 09 Jul 2014 Link to this post

    Hello Zhonghai,

    The `model` instance in the arguments reflects the current state of the model before restoring it to its pristine state. The reason for this is as the `cancel` event can be canceled.

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Zhonghai
    Zhonghai avatar
    20 posts
    Member since:
    Mar 2014

    Posted 09 Jul 2014 in reply to Nikolay Rusev Link to this post

    Good morning Nikolay,

    thanks for your clues. In this case, it make sense to keep it in the model. Is there still any way to get the original values in the cancel event? any hints si appreciated.

    thanks

    Zhonghai
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 09 Jul 2014 Link to this post

    Hello Zhonghai,

    I'm afraid that this information is not available in the public API. Can you please explain your use-case? This way we might be able to provide you a solution to the problem which you are trying to solve.

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  7. Zhonghai
    Zhonghai avatar
    20 posts
    Member since:
    Mar 2014

    Posted 09 Jul 2014 in reply to Nikolay Rusev Link to this post

    Hi Nikolay,

    many thanks for your quick back.

    Here is my case. I have two list views, each list view has a kendo ui editor as edit template (like the inline edit wyample), and these two editors have a sum of content limit (word count or line count), I need to sync the limit considering both of the editors. Since both list views are editable, in other words, could be possible in edit mode at the same time, if the user cancel edit in one of the list views, I need to get back the original value before editing to recalculate the coment limit dynamically I also use the keyup event in editors to calculate dynamically.

    that's the reason I need the orginal value in the cancel event.

    hope the case is clear for you.

    Regards

    Zhonghai
  8. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 10 Jul 2014 Link to this post

    Hello Zhonghai,

    The only way I can think of is to use timeout for checking model state. The following example demonstrates this: http://trykendoui.telerik.com/@rusev/oFEW.

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  9. Zhonghai
    Zhonghai avatar
    20 posts
    Member since:
    Mar 2014

    Posted 14 Jul 2014 in reply to Nikolay Rusev Link to this post

    Good morning Nikolay,

    thanks a ton and this works like a charm! Is there any hidden API not documentted in the online documentation?

    Regards

    Zhonghai
  10. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 15 Jul 2014 Link to this post

    Hello Zhonghai,

    I'm glad I've helped.

    Only public API is documented as it is the only API recommended to use. All other parts of the widget API are intended for internal use and it may change over time.

    Regards,
    Nikolay Rusev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready