以前遇到判断表单是否被改动的问题,昨天再次遇到,整理一下:
isDirty() : Boolean
Returns true if any fields in this form have changed from their original values.
Note that if this BasicForm was configured with trackResetOnLoad then theFields' original values are updated when the values are loaded by setValuesor loadRecord.
Parameters:
- None.
Boolean
所以在用到isDirty()的时候,在formPanel 必须配置trackResetOnLoad为true;否则会没有效果。
以前用isDirty()的时候,是由于用到了radioGroup和checkbox,这个方法就会失去效果,
我是在最开始的时候设置var flag = true;在每一个输入框里设置flag=false;通过flag来判断数据是否发生了改变。
本文讨论了如何在表单中检测数据是否发生改动,重点介绍了使用isDirty()方法时需要注意的事项,包括配置trackResetOnLoad为true的重要性,以及在遇到特定组件如radioGroup和checkbox时的方法失效情况。通过示例展示了使用flag变量来判断数据变更的实现方式。
499

被折叠的 条评论
为什么被折叠?



