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

Bind kendoValidator() object to custom grid update popup

3 Answers 274 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rasika
Top achievements
Rank 1
Rasika asked on 17 Sep 2015, 06:37 AM
I have a Kendo grid to this div
<div id="grid"></div>

Then I have a custom popup template like below...

<script type="text/x-kendo-template" id="myUpdateTemplate"><div id="tempCode">// here my template code</div></script>

In my script I have grid code and custom validation code

<script>      $(document).ready(function () {
 
     var grid = $("#grid").kendoGrid({// my grid code in here});
 
     var val = $("#grid").kendoValidator({
     // my custom validation rules and messages are here
     }).data("kendoValidator");
 
     }); <script>

My question is how I bind the validation with my update popup.
Here is ways that I try to do that : I add grid id to validation object....

var val = $("#grid").kendoValidator({
 
 
// my custom validation rules and messages are here
 
 
 }).data("kendoValidator");

Not working .....

Then I add template id to grid object ..

var val = $("#myUpdateTemplate").kendoValidator({
 
 
// my custom validation rules and messages are here
 
 
 }).data("kendoValidator");

Not working ...
Then I add a inside div id to validation object..

var val = $("#tempCode").kendoValidator({
 
 
// my custom validation rules and messages are here
 
 
 }).data("kendoValidator");

Not working.....
So I am asking can we add 
kendoValidator()
 object to custom grid update popup ??

3 Answers, 1 is accepted

Sort by
0
Pat
Top achievements
Rank 1
answered on 16 Dec 2016, 07:39 PM
Did you ever find a solution to this?  I am trying to accomplish the same, and have performed nearly the exact same steps...
0
Pat
Top achievements
Rank 1
answered on 16 Dec 2016, 07:58 PM

Never fails to find something right after posting a question...

I was able to get something working following this post: http://stackoverflow.com/a/16521485

This still feels like a bit of a workaround; performing all of the pop up validation, but configured on a single schema model fields validation configuration (and checking for specific input names in the code).

Is this really the "correct" way to do this?

0
Marin
Telerik team
answered on 21 Dec 2016, 02:44 PM
Hello,

Specifying validation in the model fields of the datasource is indeed a valid option should you chose to use it. It will also initialize kendo validator instances automatically for you when required.

The other option is to initialize your own kendo validators when the popup is open and already visible. You can try the edit event of the grid for this case:
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-edit
Other than that the code you posted for adding validator to the popup template looks correct the only thing required is to make sure the template is already created and visible on the page in order for the validation to work as expected.

Regards,
Marin
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Rasika
Top achievements
Rank 1
Answers by
Pat
Top achievements
Rank 1
Marin
Telerik team
Share this question
or