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

Adding Confirmation alert inside field validation for popup editor makes validation trigger multiple times

4 Answers 196 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Lars Lykke
Top achievements
Rank 1
Lars Lykke asked on 18 Mar 2013, 01:20 PM
I added a custom validation function for field Discount.
The problem is that the confirmation alert inside the validation function seems to make validation trigger multiple times, so that user has to confirm again and again to make popup editor go away.

Jfiddle demo here: http://jsfiddle.net/uBfQ3/1/

To reproduce:

1. Edit discount field to more than 20 and hit update
2. Observe Confirm-popup triggering several times and popup editor is still present after hitting OK in all these windows
3. Hit update and observe yet another confirmation pops up
4. Hit OK and observe that popup editor finally goes away

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 20 Mar 2013, 11:03 AM
Hi Lars,

 
Basically the validation is fired twice - once when loosing the focus of the input  when clicking the Update button (the input looses focus before the Update button click event is fired) and once for the validating all inputs in the PopUp editor after pressing the "update" button (this behavior cannot be prevented). In current case I would suggest to use the save event of the grid to display the confirmation message to the user (please check the updated Fiddle here) or implement custom code to track which validation is fired - when loosing focus of the input or clicking the "update" button. 

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Lars Lykke
Top achievements
Rank 1
answered on 02 Apr 2013, 10:04 AM
Hi Vladimir,

Thanks for your reply, however this solution still has issues:

1. It seems validation is triggered even if user presses 'Cancel'. E.g. if you set discount > 20 and hit cancel, validation message will still trigger!
2. you suggest using 'save' event, however in your code save-event does nothing besides contain debugger-statement.
I am thinking it might be the wrong code you linked to?

Thank you

L
0
Vladimir Iliev
Telerik team
answered on 02 Apr 2013, 11:28 AM
Hi Lars,

 
I updated the provided jsFiddle to use the save event of the grid to display the confirmation message, prevent the model update and trigger the validation if the user cancels the update.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Lars Lykke
Top achievements
Rank 1
answered on 08 Apr 2013, 01:02 PM
Thank you, that worked.
Tags
Data Source
Asked by
Lars Lykke
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Lars Lykke
Top achievements
Rank 1
Share this question
or