View Full Version : How to reset isDirty on a field?

16 Sep 2009, 6:52 AM
I just created a similar post here: http://www.extjs.com/forum/showthread.php?p=387342#post387342

but thought it would get buried, so I'll ask here...

I have fields (textfield, etc) on a Panel, not a Form. When I show the Panel, I load some values in the fields. I need to be able to somehow reset the isDirty for each of these fields, because it returns true since technically, the fields were empty at time of render. Again, this is on a Panel, not a Form, so I don't have the luxury of form related field functions. Any help would be appreciated.

16 Sep 2009, 7:21 AM
Think I figured it out:

Ext.override(Ext.form.Field, {
setOriginalValue: function(value) {
this.originalValue = value;

Seems to work just fine. Please let me know if you see any problem with the above.

16 Sep 2009, 7:47 AM
http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Field&member=reset ?

16 Sep 2009, 8:03 AM
http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Field&member=reset ?

That doesn't work because it clears the field. See the problem is that I'm not setting the value of the field with the value config. I am setting it in a function. So technically, the original value of the field is empty. So I need to trick it to accept a new value as the original value. My override seems to do the trick.

16 Sep 2009, 8:26 AM
The Ext.form.Field class has a private initValue() method. Each subclass overrides this method with the logic necessary for its particular implementation.

16 Sep 2009, 8:34 AM
Considering I don't see this in the docs, how is this used? I tried .initValue("myvalue"), but doesn't seem to do anything.