Bind kendoValidator() object to custom grid update popup

4 posts, 0 answers
  1. Rasika
    Rasika avatar
    18 posts
    Member since:
    Jul 2015

    Posted 17 Sep 2015 Link to this post

    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 ??

  2. Pat
    Pat avatar
    4 posts
    Member since:
    Oct 2015

    Posted 16 Dec 2016 Link to this post

    Did you ever find a solution to this?  I am trying to accomplish the same, and have performed nearly the exact same steps...
  3. Pat
    Pat avatar
    4 posts
    Member since:
    Oct 2015

    Posted 16 Dec 2016 Link to this post

    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?

  4. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 21 Dec 2016 Link to this post

    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.
Back to Top