View Full Version : How to reset isDirty() for a controls

4 Jul 2013, 7:58 AM

I am checking before closing the window isDirty() flag.
When i will save this value to me DB, that time also its giving same values.

So how i will reset this value after saving to database.
So that after saving if i will modify anything then i will get to know.

4 Jul 2013, 4:06 PM
Is this what you're looking for?

5 Jul 2013, 2:18 AM
Thanks for your reply.

still, i am not able to resolve my problem.
it will help me if you provide an example about it.

5 Jul 2013, 2:52 AM
If I unsderstood, it's



5 Jul 2013, 6:27 AM
Actually me problem is like this.

let's i have a text field control. If first time, i will check isDirty() status then i will get false.
Now i will set some value to text field, if now i will check isDirty() status then i will get true.
till now it's fine and no problem it is working for me.

No i saved my text field value to some database.
If now i will check isDirty() status then i should get false, but i am getting true.
So i will achieve this or what i will do after saving for text field, so isDirty() status will reset..

please help..

8 Jul 2013, 2:14 PM
The example at the top of the form panel's API doc shows a reset button at the bottom of the form.

Here is the same example with a "check if dirty" button.

Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,

// The form will submit an AJAX request to this URL when submitted
url: 'save-form.php',

// Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'

// The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false

// Reset and Submit buttons
buttons: [{
text: 'Reset',
handler: function() {
}, {
text: 'Check to see if Dirty',
handler: function () {
}, {
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
renderTo: Ext.getBody()

9 Jul 2013, 2:23 AM
Hello, thanks for the reply.

When i am doing reset for 'form' then all the controls get cleared.
and isDirty() working fine.

But my problem, i don't want to clear all the field. it should show all the value whatever i have before saving.
after saving isDirty() should give false.
If again i will modify anything then it should give true.

how i will reset isDirty() flag only, i do not want to clear all the field value.

9 Jul 2013, 3:12 AM
Whether sencha provide any method for 'form' to call "resetOriginalValue()" for all the controls of form.

i mean is there any way or method to get all the controls item id to call "resetOriginalValue()" method.
or any method which will call "resetOriginalValue()" method for all the controls.

11 Jul 2013, 8:44 PM
You might look at loading the form with a record using loadRecord. When you reset() a form that was loaded with a record you can choose whether to reset completely or just back to the values loaded from the record.

When changes occur in the form you can use updateRecord. And instead of using the form's submit action you can give the record a proxy and use the record's save() method to save values back to the server.