Search code examples
javascriptextjsextjs4

Extjs - reset() not loading last value when trackResetOnLoad is true


Extjs documentation trackResetOnLoad

If set to true, reset() resets to the last loaded or setValues() data instead of when the form was first created. Defaults to: false

In my form i set trackResetOnLoad true and In Afterrender function i updated value using setValue() and called Reset function. trackResetOnLoad not reset to last value( setvalue()).

am i wrongly using trackResetOnLoad config option ? if possible please explain how will reset, setValue and trackResetOnLoad will work together. Thanks.

Fiddle https://fiddle.sencha.com/#fiddle/1d8m

Note:- its not duplicate post. this post didn't answer extract question.


Solution

  • When Field.setValue() is called, isDirty() is set to true. To keep the form non-dirty after setValue(), you should call resetOriginalValue() on the corresponding field.

    Ext.ComponentQuery.query('#username')[0].setValue ('stackoverflow');
    Ext.ComponentQuery.query('#username')[0].resetOriginalValue();
    Ext.ComponentQuery.query('#panelFormID')[0].trackResetOnLoad = true;
    Ext.ComponentQuery.query('#panelFormID')[0].reset();