将验证器添加到 smartgwt 中现有的 FormItem 验证器中
在 smartgwt DynamicForm 中,如何将验证器添加到 FormItem 内的现有验证器集?
我在官方api中找到的唯一方法是“setValidator(Validator)”,但这似乎覆盖了所有现有的方法。
我更喜欢使用 java 方法(即使用 smartgwt api),但最终,如果没有可用的解决方案,至少“js”本机方法可以完成这项工作。
谢谢
in a smartgwt DynamicForm, how can I add a validator to an existing set of validators within a FormItem ?
The only method I found in the official api is "setValidator(Validator)", but this seems to overwrite all the existing ones.
I would prefer a java approach to this (i.e. using smartgwt api), but in the end, if no solutions are available, at least a "js" native method would do the job.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,您根本不想尝试动态添加验证器。
首先,阅读快速入门指南的数据绑定部分,其中展示了如何将特定于屏幕的验证器添加到表单,同时仍然继承在数据源中声明的验证器。
其次,如果您尝试动态更改验证器列表,因为验证所依赖的某些数据正在更改,请查看 CustomValidator。
如果您出于某种原因动态添加这些方法无法处理的验证器,请尝试详细解释它。
最后,如果您只是进行重构,以便可以在单个 setValidators() 调用中向 FormItems 提供所有适当的验证器,则可以继续使用当前的方法(不推荐)。
Most likely, you don't want to by trying to dynamically add a validator at all.
First, read the Data Binding section of the QuickStart Guide, which shows how you can add screen-specific validators to a form while still inheriting validators declared in the DataSource.
Second, if you're trying to dynamically change the list of validators because some data that validation depends on is changing, take a look at the CustomValidator instead.
If you have some reason to add a validator dynamically that isn't handled by these approaches, try explaining it in detail.
Finally, you can continue with your current approach (not recommended) if you just refactor such that you can provide all the appropriate validators to the FormItems in a single setValidators() call.