1. #1
    Ext User
    Join Date
    Nov 2008
    Vote Rating
    rosemondi is on a distinguished road


    Default form isDirty() always return true, when using itemselector and loading data for it...

    I meet an issue about isDirty() and ItemSelector.

    There is an itemselector in a form and the data is dynamically loaded to the form fields by ajax (the selected and from store of itemselector will be changed based on loading data). Although'trackResetOnload" is set to true, form.isDirty() always returns true.

    Is there something like originalValue of itemselector? If so, after loading, i can manually reset its original value. Or are there any other smart methods to handle it?


  2. #2
    Sencha User
    Join Date
    Jan 2011
    Vote Rating
    rborg is on a distinguished road


    Default For anyone else still experiencing this issue

    here is a fix, combined with a fix provided by tungj (OPEN-1200] Ext.ux.form.ItemSelector leak due to ItemSelector.js line 93/117) that solves both problems for the itemSelector

    var origRender = Ext.ux.form.ItemSelector.prototype.onRender;
    var origBeforeDestroy = Ext.ux.form.ItemSelector.prototype.beforeDestroy;
    Ext.override(Ext.ux.form.ItemSelector, {
        beforeDestroy: function(){
            origBeforeDestroy.apply(this, arguments);
            if (this.rendered) {
                // Need to deregister the click listeners otherwise the selector and children will leak
                this.toTopIcon.un('click', this.toTop, this);
                this.upIcon.un('click', this.up, this);
                this.downIcon.un('click', this.down, this);
                this.toBottomIcon.un('click', this.toBottom, this);
                this.addIcon.un('click', this.fromTo, this);
                this.removeIcon.un('click', this.toFrom, this);
        onRender: function() {
            origRender.apply(this, arguments);
            // Want to destroy the panel containing the multiSelects, but it's internal
            // so have to access it via ownerCt
            var leakPanel = this.toMultiselect.ownerCt;
            this.on('destroy', leakPanel.destroy, leakPanel);
        afterRender: function(){
            this.toStore = this.toMultiselect.store;
            this.toStore.on('add', this.valueChanged, this);
            this.toStore.on('remove', this.valueChanged, this);
            //change for a custiom load not value changed as in original code
            this.toStore.on('load', this.valueLoad, this);
        valueLoad: function(store) {
            var record = null;
            var values = [];
            for (var i=0; i<store.getCount(); i++) {
                record = store.getAt(i);
            var valuesToSet = values.join(this.delimiter);
            this.hiddenField.dom.value = valuesToSet;
            this.originalValue = valuesToSet;

Thread Participants: 1