PDA

View Full Version : BasicForm isDirty() is not work with trackResetOnLoad option



alexey.goloburdin
26 Mar 2011, 7:56 AM
Hi to all!

Extjs API docs contains (http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.BasicForm) some information about isDirty() method of BasicForm element:

Returns true if any fields in this form have changed from their original values.
Note that if this BasicForm was configured with trackResetOnLoad then the Fields' original values are updated when the values are loaded by setValues or loadRecord.

So, if i set trackResetOnLoad to TRUE in BasicForm or FormPanel config, isDirty() must return false after setValue() action applied to one of form fields. But it not works for me!

For example, i write this code:

var form = new Ext.FormPanel(
{
renderTo: Ext.getBody(),
frame: true,
title: 'My test form',

trackResetOnLoad: true, // note, please

items: [
{
xtype: 'textfield',
fieldLabel: 'First field',
name: 'first'
}
]
}
);

console.log(form.getForm().isDirty()); // return FALSE

// set some value to Form element...
form.getForm().findField('first').setValue('some value');

console.log(form.getForm().isDirty()); // return TRUE


Last isDirty() call must return false. What's wrong?

PS. Sorry for my English, yeah.

fay
26 Mar 2011, 8:28 AM
I think you've mistaken setValue (no "s"!) with setValues as the docs say.

alexey.goloburdin
26 Mar 2011, 9:00 AM
fay, thanks for answer! You are quite right.
But what is about clear dirty mark after setValue() to some form field?

dmackerman
16 Sep 2011, 6:45 AM
I would like an answer to this as well. I'm using setValue() on specific fields, and I need to clear their dirty marker...doesn't seem like there's an easy way to do that.