PDA

View Full Version : [CLOSED] Formpanel - set isDirty() to false onload of page



PriceRightHTML5team
Aug 03, 2013, 6:31 AM
Hi,
In my cshtml page, i have a formpanel.
This formpanel has lots of controls within it.
On Ext.onReady() i set values to some of the controls, so for the formpanel FieldChange event is getting triggered.
Now on a buttons click (even when user has not changed any field value) i check for formpanel isDirty(). it always returns true.
As a thought is it possible to set isDirty of the form to false after setting control values in Ext.onReady event.
So as to trap user made change again through isDirty().

Daniil
Aug 05, 2013, 5:11 AM
Hi @PriceRightHTML5team,

I think it could be enough to set up TrackResetOnLoad="true" for a FormPanel in your scenario.
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.Basic-cfg-trackResetOnLoad

PriceRightHTML5team
Aug 05, 2013, 6:25 AM
Hi Daniil,
I Applied to the form

.TrackResetOnLoad(true)
but still

App.FrmEditRefRules.getForm().isDirty()
is always true (even when user has not made any changes to the form controls).

Following is my script in Ext.onReady event.


Ext.onReady(function(){
App.cntrlnm.hide(); // Hide Alternate Accordian
App.Cmbxyz.setValue('@ViewBag.Selectedxyz');
});

Daniil
Aug 05, 2013, 6:36 AM
I thought you use a form's setValues method.

For you case, you should make a field not dirty.

App.Cmbxyz.setValue('@ViewBag.Selectedxyz');
App.Cmbxyz.originalValue = App.Cmbxyz.getValue(); // to reset its dirty

PriceRightHTML5team
Aug 07, 2013, 9:29 AM
Hi Daniil,
I checked the value of isDirty() at very begining of Ext.onRead() i.e. before setting/updating control values to through script, it is true


Ext.onReady(function(){
App.Frmnm.getForm().isDirty(); // shows true
App.cntAltPanel.hide();
App.Cmbbox.setValue('@ViewBag.SelectedCountry');
App.CmbboxoriginalValue = App.Cmbbox.getValue();

I guess it should have been false

Daniil
Aug 07, 2013, 12:39 PM
Please provide a test case.