PDA

View Full Version : Reset isDirty to false over ExtJS window



Pravin.Pawar
12 Feb 2013, 7:27 AM
Hi,

I have form window which has multiple tabs and lot of text, combo box controls.

On window close button; I have to prompt user for save yes/ no if there are any changes done over the dialog by user.

I know the window has isDirty property which is false by default somehow I'm using window dialog to edit records and i have to show current data over the dialog which makes isDirty to true when I'm filling controls.

Please let me know is there is any way to make isDirty false after I fill all control values.

mitchellsimoens
13 Feb 2013, 8:48 PM
You can handle the beforehide/beforedestroy event of the window and return false if you need to ask the user to confirm window close. Have the event have single : true, if the user chooses to stop close then add the beforehide/beforedestroy event to the window again.

Pravin.Pawar
14 Feb 2013, 9:33 AM
I think you didn't get my question.

I have list of the records on dashboard and from Edit button click; I'm populating records over the ExtJS form so that user can do necessary changes.

My question is if user do any changes on the ExtJS form then while closing window I have to prompt "You have not saved your changes, do you want to close this window?" and if user just opens window and do nothing then I have to close window without asking anything because we should prompt only if the window is modified with any changes.

I know the window has isDirty() method which tells if there are any changes somehow as I'm opening window to edit records and populating existing values within the controls while opening the window.

As I'm filling all the controls on load; window makes isDirty() value true and I'm NOT able to know how can I identify that the use has done any changes on the window.

I think; I will need to reset isDirty() of window after populating values on all the controls on window load.

Please let me know how should I reset isDirty() dynamically

droessner
14 Feb 2013, 10:08 AM
It sounds like you are looking for the resetOriginalValue method. This method will set the fields original value to the current value which will also clear the dirty flag on the field.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Field-method-resetOriginalValue

Pravin.Pawar
21 Feb 2013, 6:01 AM
But I dont want to clear window.. is there any way through which we can reset isDirty flag without changing values from window?