【发布时间】:2015-12-28 11:30:39
【问题描述】:
我目前正在以模式显示 Kendo UI Grid。我已经连接了一些自定义验证,它们运行良好。当模态框的“保存”按钮被点击时,我需要能够检查网格当前是处于有效还是无效状态。
由于我只使用自定义验证,我当然可以跟踪错误,然后在模式关闭时检查错误计数,但我希望 Kendo UI Grid 跟上这一点并暴露出来像 myGrid.isValid() 这样简单的东西。
【问题讨论】:
标签: kendo-ui kendo-grid
我目前正在以模式显示 Kendo UI Grid。我已经连接了一些自定义验证,它们运行良好。当模态框的“保存”按钮被点击时,我需要能够检查网格当前是处于有效还是无效状态。
由于我只使用自定义验证,我当然可以跟踪错误,然后在模式关闭时检查错误计数,但我希望 Kendo UI Grid 跟上这一点并暴露出来像 myGrid.isValid() 这样简单的东西。
【问题讨论】:
标签: kendo-ui kendo-grid
如果你在服务器端使用 web-api 调用ModelState.IsValid
custom validation 是什么意思?
如果您使用 kendo custom validation 像此参考中的 reference 这样用户不能在编辑器中输入错误的值。但是如果你想要 IsValid 选项,那么你需要隐含kendo.validator。在模型中定义验证 rools,然后调用 validate():
// attach a validator to the container and get a reference
var validatable = $("#myform").kendoValidator().data("kendoValidator");
$("#save").click(function() {
//validate the input elements and check if there are any errors
if (validatable.validate() === false) {
// get the errors and write them out to the "errors" html container
var errors = validatable.errors();
$(errors).each(function() {
$("#errors").html(this);
});
}
});
【讨论】: