Can we do validation inside the client detail template?

2 posts, 0 answers
  1. Karthik
    Karthik avatar
    1 posts
    Member since:
    Sep 2012

    Posted 06 Mar 2015 Link to this post

     Hello All,
            I have a client detail template like this,
    <script id="ItemsMoreTemplate" type="text/x-kendo-template">
    <div class="form-group required">
            <div class="col-sm-2 control-label">
                @Html.LabelFor(x => x.Expire1Message)
            </div>
            <div class="col-sm-3">            
                @Html.Kendo().TextBoxFor(x => x.Expire1Message).HtmlAttributes(new { , required=true ,id = "Expire1Message_#=Id#", @class = "form-control", value = "#if(Expire1Message!=null){##=Expire1Message##}#" })
                
            </div>
        </div>
    </script>

    I am just expanding this template when I click the edit button (just expanding on edit event from grid) and the data are binding well. 
     I updated the post data source on Save event of kendo grid. Anyway the value is updating and getting saved.
     But my problem is the validation, original grid text boxes are validating well, but my client template text boxes are not validating, because no validation message or required attributes are added to the text box. 

    Is there any way to do validate the client detail template text boxes??
    Kindly advice me.
     


  2. Daniel
    Admin
    Daniel avatar
    2230 posts

    Posted 10 Mar 2015 Link to this post

    Hello,

    The detail is not part of the editing container so the grid validator will not validate the inputs. You should initialize a validator in the detailInit event:
    function onDetailInit(e) {
        e.detailRow.kendoValidator();
    and then check if the inputs are valid in the save event by using the validate method:
    function onSave(e) {
        var detailValidator = e.container.next().data("kendoValidator");
        if (!detailValidator.validate()) {
                e.preventDefault();
        }


    Regards,
    Daniel
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top