gpt4 book ai didi

smartgwt - 为什么不能向 DynamicForm 或 FormItem 添加 EditorExit 处理程序?

转载 作者:行者123 更新时间:2023-12-04 12:48:58 24 4
gpt4 key购买 nike

此处理程序仅适用于 ListGrid。

但是,如果您查看 DynamicForm.setValidateOnExit() 的文档,它会说:

If true, form items will be validated when each item's "editorExit" handler is fired as well as when the entire form is submitted or validated.

Note that this property can also be set at the item level to enable finer granularity validation in response to user interaction - if true at either level, validation will occur on editorExit.



那么我们如何将 EditorExitHandler 添加到 DynamicForm 或 FormItem 中呢?

编辑:

我想在表单下方创建一个错误面板来动态显示所有错误。每个 FormITem 都有可能在退出时进行验证,但我不知道如何捕获此验证事件以检查是否应更新错误面板。

最佳答案

有一种方法 form.getErrors()form.showError(true) .这样你就可以实现了。但为此,您还需要为每个字段设置验证器。

TextItem name = new TextItem("name", "Name");
name.setRequired(true);
name.setRequiredMessage("Please specify name of the Table");

NTRegExpValidator nameValidator = new NTRegExpValidator("(^[a-zA-Z0-9][\\w\\s.()_-]+)$","It should start with alphabets and can have alphanumeric values ( )_-. and space.");

name.setValidators(nameValidator);
name.addKeyUpFieldHandler(new KeyUpHandler){
form.getErrors();
form.showErrror(true);
});

DynamicForm form = new DynamicForm();
form.setField(name);

关于smartgwt - 为什么不能向 DynamicForm 或 FormItem 添加 EditorExit 处理程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9923761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com