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

grid validation

5 Answers 309 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 25 Feb 2013, 03:28 PM
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

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Feb 2013, 12:42 PM
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!
0
Daniel
Top achievements
Rank 1
answered on 28 Feb 2013, 10:14 AM
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
0
Daniel
Telerik team
answered on 04 Mar 2013, 08:05 AM
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!
0
Daniel
Top achievements
Rank 1
answered on 05 Mar 2013, 08:38 AM
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
0
Accepted
Daniel
Telerik team
answered on 07 Mar 2013, 07:27 AM
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!
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or