Hello,
I've a view with one Form and one Kendo Grid like this
01.
<div>
02.
<form id=
"form1"
>
03.
</form>
04.
</div>
05.
06.
<div>
07.
@(Html.Kendo().Grid<ProductsModel>()
08.
.Name(
"grid"
)
09.
.....
10.
)
11.
</div>
The grid is using a custom popup editor's template like this
1.
<form id=
"gridEditorTemplate"
>
2.
....
3.
</form>
I've defined a kendo validator for the form1 in this way
01.
var validator1 = $(
"#form1"
).kendoValidator({
02.
rules: {
03.
customRule1: function (input) {
04.
// all of the input must have a value
05.
return
$.trim(input.val()) !==
""
;
06.
},
07.
},
08.
messages: {
09.
customRule1:
"All fields are required"
,
10.
}
11.
}).data(
"kendoValidator"
);
This validator work in the way I expected but when I define a new validator like this one for the gridEditorTemplate the custom rule isn't called by the grid when the user click the Update button.
However if I declare the custom rule for the popup editor like this
01.
(function ($, kendo) {
02.
$.extend(
true
, kendo.ui.validator, {
03.
rules: {
04.
positive: function (input) {
05.
if
(input.attr(
"id"
) ===
"xx"
) {
06.
var val = input.val();
07.
if
(val !==
""
) {
08.
return
val > 0;
09.
}
10.
}
11.
return
true
;
12.
}
13.
},
14.
messages: {
15.
positive: function (input) {
16.
return
"positive"
;
17.
}
18.
}
19.
});
20.
})(jQuery, kendo);
it works as expected.
The problem with this approach is that when I call validate() for the form1 like this validator1.validate() the rules defined in the popup editor's validator are analyzed too.
What I need is to define a validator for the popup editor's template in such a way that when I call validator1.validate() it doesn't analyze the rules defined in the popup editor's template.
Thank you.