Validation 剑道UI网格内联编辑定义最小验证的自定义值
我正在使用剑道网格,希望通过同一记录中的另一个字段验证一个字段的最小值 意思是我的数据如下:-Validation 剑道UI网格内联编辑定义最小验证的自定义值,validation,kendo-ui,kendo-grid,inline-editing,custom-validators,Validation,Kendo Ui,Kendo Grid,Inline Editing,Custom Validators,我正在使用剑道网格,希望通过同一记录中的另一个字段验证一个字段的最小值 意思是我的数据如下:- var courses = [{ CourseID : 1, CourseName : "iPhone", MinAge: 12, MaxAge : 22, MinAgeThreshold : 10, MaxAgeThreshold : 30, StartDate: "12/10/2014", }, { CourseID : 2,
var courses = [{
CourseID : 1,
CourseName : "iPhone",
MinAge: 12,
MaxAge : 22,
MinAgeThreshold : 10,
MaxAgeThreshold : 30,
StartDate: "12/10/2014",
},
{
CourseID : 2,
CourseName : "Android",
MinAge: 12,
MaxAge : 22,
MinAgeThreshold : 10,
MaxAgeThreshold : 30,
StartDate: "12/10/2014",
}]
我想在MinAge的validation min值中使用MinAgeThreshold值,如下所示:-
schema: {
model: {
id: "CourseID",
fields: {
CourseID: { editable: false, nullable: true },
StartDate: { editable: false, nullable: true },
CourseName: { editable: false, nullable: true },
MinAgeThreshold: { editable: false, nullable: true },
MinAge: { type: "number", validation: { required: true, min: MinAgeThreshold} },
MaxAge: { type: "number", validation: { required: true, min: 1} },
}
这有可能吗
我尝试在验证中使用这样的自定义函数
MinAge: {
type: "number",
validation: {
required: true,
minagevalidation: function (input) {
}
},
但我无法在minagevalidation函数中检索MinAgeThreshold的值
任何帮助都将不胜感激
关于您可以尝试下面给出的方法来给出自定义验证消息,并强制用户根据同一剑道网格中的其他输入字段设置大于最小值的值。
MinAge: { type: "number",
validation: {
required: true,
MinAgevalidation: function (input) {
if(input.is("[name='MinAge']") &&(parseInt($("input[type='text'][name='MinAge']").val()) < parseInt($("input[type='text'][name='UnitPrice']").val()))){
input.attr("data-MinAgevalidation-msg", "MinAge should greater than MinAge threshold");
return false;
}
return true;
}
MinAge:{type:“number”,
验证:{
要求:正确,
MinAgevalidation:函数(输入){
如果(input.is(“[name='MinAge']”)和(parseInt($([input[type='text'][name='MinAge']]).val())
我想我可能有一个解决这种问题的方法。如果你想通过不同字段的值设置字段的最大值,你可以将其添加到kendogrid的网格编辑方法中
var grid = $("#grid").kendoGrid({
edit: function(e){
if ( e.container.find("input[data-find='value:MinAge']).length != 0 ){
var numericTextBox = e.container.find("input[data-find='value:MinAge']).data("kendoNumericTextBox");
numericTextBox.min(e.model.MinAgeThreshold);
}
}
});
这会将MinAge输入的numerictTextBox设置为行(模型)数据项中MinAgeThreshold的最小值。这也适用于step、max等。输入字段时会触发编辑。因此,如果初始值为0且MinAgeThreshold为其他值,则会切换到MinAgeThreshold