Kendo MVC Editable Grid - Numeric TextBox Not working

2 posts, 0 answers
  1. Aarti
    Aarti  avatar
    20 posts
    Member since:
    Mar 2014

    Posted 30 Mar 2015 Link to this post

    Hi,

    I have Kendo MVC editable Grid  with Custom EditorTemplate for Numeric Text Box. For some reason I am getting validation error icon when i  try to update the value in numeric text box as in attached file.

    I am not sure what kind of validation it is triggering as I have only required field validation. Can you pelase help me ASAP on this.


    My model is as below

    [Serializable]
        public class DocTypesModel
        {
            [Required(ErrorMessage = "required")]
            [UIHint("NumericTextBoxWithLimitsTemplate")]
            public int Order { get; set; }

            public int TotalCount { get; set; }

            public string DocumentTypeShortName { get; set; }      

        }

    My grid is as below


     @(Html.Kendo().Grid(Model.DocTypesModel)
                          .Name("BookmarkDoctypeGrid")
                       
                         .Columns(columns =>
                          {
                                columns.Bound(c => c.Order).Sortable(false).EditorTemplateName("NumericTextBoxWithLimitsTemplate");
                              columns.Bound(c => c.DocumentTypeShortName).Title("Document Type").Sortable(false);
                            
                          })
                          .Editable(e => e.Mode(GridEditMode.InCell))
                          .Sortable()
                          .Events(e => e.DataBound("OnGridDocTypeDataBound").SaveChanges("SaveDocTypeChanges"))
                          .Resizable(resiz => resiz.Columns(false))
                          .DataSource( dataSource =>
                              dataSource.Ajax()
                               .AutoSync(true)
                               .ServerOperation(false)
                              .Update("Editing_Update", "Bookmark")
                                  .Events(events => events.Error("error_handler"))
                            
                          )
                          )

    I have created below custom editor for  NumericTextBoxWithLimitsTemplate under /views/shared/EditorTemplates/NumericTextBoxWithLimitsTemplate.cshtml

    @model int

    @(Html.Kendo()
    .NumericTextBox().Step(1)
        .Name("Order").Decimals(0)
        .HtmlAttributes(new { Style = "width:70px;", required="required"})
             .Min(1).Max(short.MaxValue)
             
          

    Thanks,
    AArti



  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 01 Apr 2015 Link to this post

    Hello Aarti,

    Could you please try using NumercTextBoxFor as shown below:

     

    @(Html.Kendo().NumericTextBoxFor(m => m)
    )

     

    Regards,
    Boyan Dimitrov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top