ExtJS 3.4 form表单中isDirty()的使用方法
2014-10-08 10:13
246 查看
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 bysetValuesor
loadRecord.
Parameters:
None.
Returns:
那么:
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 bysetValuesor
loadRecord.
Parameters:
None.
Returns:
Boolean
以前写过同样的一个问题,不是很全面,解释的也不明确。现在整理一下:
在form表单中,判断是否表格中的数据发生变化,可以使用isDirty()方法。
注意:如果表单中字段是原始的值,没有改变,即:数据刚load完,这个时候为原始值;
如果数据在load完后,又进行了setValue操作,则数据发生改变,isDirty返回的值为:true;
这样就无法使用isDirty;所以如果想使用isDirty进行判断是,需没有set表格值;
此外还有需在formPanel 必须配置trackResetOnLoad为true;
如下:
如果在load数据时,对表单中的数据进行setValue: personForm.load({ url : 'xxxxx', success : function(form, action) { var json = Ext.decode(action.response.responseText); personForm.getTopToolbar().getComponent('personInfoStatus').setValue(json.rows[0].status); personForm.getForm().findField('experience').setValue(json.rows[0].experience); }, failure : function(response, options) { Ext.Msg.alert("提示信息", "不在转正定级范围内!"); } })
那么:
if (personForm.getForm().isDirty()) { Ext.Msg.alert('提示', '请对数据进行修改'); return; } 将始终会提示“请对数据进行修改”
相关文章推荐
- ExtJs 备忘录(1)—— Form表单(一) [ 控件使用 ](2)
- Extjs form validate表单验证使用心得
- 浅谈在Delphi中Dll调试方法以及怎样在Dll中使用数据模块DataModule(或表单Form)
- php+html5使用FormData对象提交表单及上传图片的方法
- easyui的form表单的load方法和uploadify一起使用时出现连接中止的解决办法
- ExtJS的使用方法汇总(2)——表单与输入控件
- HTML5 form标签之解放表单验证、增加文件上传、集成拖放的使用方法
- ExtJS的使用方法汇总(2)——表单与输入控件
- ExtJS4组件_form表单配置-属性-方法详解
- jQuery.validator.addMethod自定义验证方法【在表单验证中的使用 $("#appEdit_Form").validate({rules : {},messages:{}】
- ExtJS的使用方法汇总(2)——表单与输入控件
- ExtJS的使用方法汇总2——表单与输入控件
- jqTransform form表单美化插件使用方法
- 使用jquery 的form的submit()方法表单不提交的原因
- ExtJs 备忘录(1)—— Form表单(一) [ 控件使用 ]
- 使用get方法提交form表单时出现乱码解决方法
- ExtJS4组件_form表单配置-属性-方法详解
- ExtJS的使用方法汇总2——表单与输入控件
- 使用get方法提交form表单时出现乱码解决方法
- ExtJs 备忘录(1)—— Form表单(一) [ 控件使用 ]