我有一个Kendo配置为批处理编辑。在调用网格的CRUD函数之前,我希望实现的是网格级别的自定义验证。因此,假设网格显示一个员工列表,用户使用相同的EmployeeID添加两个雇员;然后单击“保存更改”,网格应该调用自定义验证器规则(例如,我们有一个规则来检查所有employee id是否都是唯一的)。根据验证结果,网格应该决定是否调用它的创建/更新/销毁函数。
如果有人能对我的关切作出回应,我将不胜感激。
我的剑道格网:
<div id="allocGrid" kendo-validator="ctrl.allocationGridValidatorRules" kendo-grid k-options="ctrl.allocationGridOptions(dataItem)"></div>验证规则:
ctrl.allocationGridValidatorRules = {
rules: {
customRule1: function (input) {
// this rule may check if all the employee Id's in the grid are unique
}
},
messages: {
customRule1: "Enter a unique Employee Id"
}
};我指的是以下链接:
http://jsfiddle.net/davidsalahi/qMRBc/
http://demos.telerik.com/kendo-ui/validator/angular
发布于 2015-12-09 18:21:13
如果您正在进行批处理编辑,并且希望检查副本,我建议您使用saveChanges事件,在那里您可以对e.sender.dataSource进行检查,并在需要时停止保存更改。
saveChanges: function(e) {
if (!confirm("Are you sure you want to save all changes?")) {
e.preventDefault();
}发布于 2015-12-09 16:41:03
在这种情况下,您需要在绑定到网格的DataSource中创建自定义验证。例如,您可以这样做:
employees = new kendo.data.DataSource({
schema: {
model: {
fields: {
EmployeeID: {
validation: {
employeeidvalidation: function(input){
if(input.is('[name="EmployeeID"]'){
//Implement custom validation here...
}
return true;
}
}
}
}
}
}
});https://stackoverflow.com/questions/34180684
复制相似问题