View Full Version : IsDirty is always true when using form.loadRecord

28 Mar 2011, 2:42 PM
When I call isDirty on a field, within my basic form, it always comes back as true.

It looks like myform.loadRecord(...) does not set the dirty flag back to false, when
it is done setting the fields on the form with my model data.

28 Mar 2011, 3:20 PM
It sounds like you're not setting trackResetOnLoad:true on the form. Without that, isDirty will base itself on the original values from when the form was created.

Note that in PR5 there was a bug with trackResetOnLoad where the dirtyCls would not be removed when loadRecord is called: http://www.sencha.com/forum/showthread.php?128237-2-FormPanel-issues-%28trackResetOnLoad -- But isDirty should still work as expected.

28 Mar 2011, 3:28 PM
That's good to know about the bug. Also, no I was not setting trackResetOnLoad... So it's now "working"

However, I just can't imagine this is the way it should work. The most obvious solution is when you use loadRecord (should be called loadModel now BTW), that the default for trackResetOnLoad is TRUE, not false.

The better solution is to also set the initial dirty state of the form with the current dirty state from the model.

The best solution is bi-directional binding :D

But anyway, what is the reason behind having trackResetOnLoad default to false in the case of using loadRecord? Seems counter intuitive to me!

28 Mar 2011, 3:34 PM
Honestly I couldn't tell you why it is this way, but this has been the behavior for ages, at least since Ext 1.1.

8 Jul 2011, 4:38 AM
Im using ExtJS4.0.2a, and found this behaviour still exists.
In Ext3 when i set trackResetOnLoad:true, the loadRecord sets isDirty:false