grid validation

6 posts, 1 answers
  1. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 25 Feb 2013 Link to this post

    Hello,
    If we use inline of batch edit mode for the grid,can i use  validations  if i add DataAdnotations on my Model/ViewModel or what kind of validations is possible?

    Regards,
    Daniel
  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 27 Feb 2013 Link to this post

    Hello Daniel,

    Yes, the Data Annotation attributes can be used when the kendo.aspnetmvc JavaSript file is included. It will automatically convert the unobtrusive attributes to rules of the Validator. The currently supported attributes are Required, StringLength, RegularExpression and Range. The automatic validation for numbers and dates is also supported.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 28 Feb 2013 Link to this post

    yes i figure it out. if i put adnotation attributes directly on the model class and it was not working .If i added a viewModel and put there adnotation attributes then it works,showing to me messages.Also i noticed that the messages have an arrow that theoretically points to the control being validated.But when i have many columns in a grid,the messages do not point the right controls. can i make  visual adjustments to the alignment of the validation messages?

    regards,
    Daniel
  4. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 04 Mar 2013 Link to this post

    Hello again Daniel,

    I am not sure what is causing the problem with the messages display. Does the problem occur in the offline demos. If not, could you share a runnable sample? 
    In order to adjust the styles for the messages, you can add the styles to the elements with class "k-invalid-msg".

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Daniel
    Daniel avatar
    192 posts
    Member since:
    Mar 2012

    Posted 05 Mar 2013 Link to this post

    But,where it is the default settings for this messages?
    where can i find this class k-invalid-msg,can you show me also a small example with changing the position of the messages below?

    Regards,
    Daniel
  6. Answer
    Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 07 Mar 2013 Link to this post

    Hello Daniel,

    There is not a configuration for the error messages in the Grid. You could override the margin using an important rule for the style e.g.

    .k-invalid-msg
    {
        margin: 0 !important;
    }
    The alternative is to override the errorTemplate of the editable implementation:
    kendo.ui.Editable.prototype.options.errorTemplate =
        '<div class="k-widget k-tooltip k-tooltip-validation" style="margin:0"><span class="k-icon k-warning"> </span>#=message#<div class="k-callout k-callout-n"></div></div>';

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top