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

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

8 Answers 67 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Zhonghai
Top achievements
Rank 1
Zhonghai asked on 07 Jul 2014, 08:58 AM
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

8 Answers, 1 is accepted

Sort by
0
Zhonghai
Top achievements
Rank 1
answered on 07 Jul 2014, 01:05 PM
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.
0
Nikolay Rusev
Telerik team
answered on 09 Jul 2014, 06:56 AM
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!
 
0
Zhonghai
Top achievements
Rank 1
answered on 09 Jul 2014, 06:59 AM
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
0
Nikolay Rusev
Telerik team
answered on 09 Jul 2014, 08:58 AM
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!
 
0
Zhonghai
Top achievements
Rank 1
answered on 09 Jul 2014, 09:09 AM
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
0
Accepted
Nikolay Rusev
Telerik team
answered on 10 Jul 2014, 07:51 AM
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!
 
0
Zhonghai
Top achievements
Rank 1
answered on 14 Jul 2014, 06:51 AM
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
0
Nikolay Rusev
Telerik team
answered on 15 Jul 2014, 06:46 AM
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!
 
Tags
ListView
Asked by
Zhonghai
Top achievements
Rank 1
Answers by
Zhonghai
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or