• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Problem Resetting Form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem Resetting Form

    Hi,

    I have the following code that pops up a window an renders a form within it.

    Code:
    Ext.define('MaintainWarehouse.view.MaintenanceWindow', {
        alias: 'widget.maintenancewindow',
        closeAction: 'hide',
        extend: 'Ext.window.Window',
        height: 300,
        layout: 'border',
        modal: true,
        mode: null,
        modetype: null,
    	requires: [
            'MaintainWarehouse.view.MaintenanceWindowDocument',
            'MaintainWarehouse.view.MaintenanceWindowTaskGroup'
        ],
        resizable: false,
    	title: iwmlit.documentdetail,
    	width: 596,
    
    
        initComponent: function() {
            Ext.apply(this,{
                dockedItems: this.buildDockedItems(),
                items: this.buildItems(),
                systemCodes: this.buildSystemCodes()
            });
            this.callParent(arguments);
        },
    
    
    	buildItems: function() {
    		return {
                items: [{
                    itemId: 'maintenancewindowdocument',
                    xtype: 'maintenancewindowdocument'
                },{
                    itemId: 'maintenancewindowtaskgroup',
                    xtype: 'maintenancewindowtaskgroup'
                }]
            };
    	},
    
    
    	buildDockedItems: function() {
    		return [{
                dock: 'bottom',
                items: [{
                    handler: this.saveForm,
                    scope: this,
                    text: iwmlit.save,
                    tooltip: 'save',
                    ui: 'wmsblue',
                    width: 90,
                    xtype: 'basebutton'
                },{
                    handler: function() {
                        this.hide();
                    },
                    itemId: 'cancelbutton',
                    scope: this,
                    text: iwmlit.cancel,
                    tooltip: 'cancel',
                    ui: 'wmsred',
                    width: 90,
                    xtype: 'basebutton'
                }],
                layout: {
                    type: 'hbox',
                    pack: 'center'
                },
                ui: 'footer',
                xtype: 'basetoolbar'
    		}];
    	},
    
    
        buildSystemCodes: function() {
    
    
            // Create system codes stores;
            WMS.util.Helper.createSystemCodeStore([
                'TAGP'
            ]);
        },
    
    
    	setDetail: function(rec, mode, modetype) {
    
    
            this.mode = mode;
            this.modetype = modetype;
    
    
            switch(this.modetype) {
    
    
                case 'document':
                    this.down('maintenancewindowtaskgroup').hide();
                    this.down('maintenancewindowdocument').getForm().reset();
                    this.down('maintenancewindowdocument').show();
                    if (this.mode === 'update') {
                        this.setTitle(iwmlit.documentdetails + ' - ' + rec.data.DODS931);
                        this.down('maintenancewindowdocument').getForm().setValues(rec.data);
                    } else {
                        this.setTitle(iwmlit.documentdetails);
    //                    this.down('#DOCD935').setValue('');
    //                    this.down('#PTCD935').setValue('');
    //                    this.down('#COPY935').setValue('');
    //                    this.down('#SAVE935').setValue('0');
                    }
                    break;
    
    
                case 'taskgroup':
                    if (this.mode === 'update') {
                        this.setTitle(iwmlit.taskgroupdetails + ' - ' + rec.data.MCDS921);
                        this.down('maintenancewindowtaskgroup').getForm().setValues(rec.data);
                    } else {
                        this.setTitle(iwmlit.taskgroupdetails);
                        this.down('maintenancewindowtaskgroup').getForm().reset();
                    }
                    this.down('maintenancewindowdocument').hide();
                    this.down('maintenancewindowtaskgroup').show();
                    break;
    
    
            }
    
    
    	},
    	
    	saveForm: function() {
    
    
            switch(this.modetype) {
    
    
                case 'document':
                    var form = this.down('maintenancewindowdocument').getForm();
                    break;
    
    
                case 'taskgroup':
                    var form = this.down('maintenancewindowtaskgroup').getForm();
                    break;
    
    
            }
    
    
            if (form.isValid()) {
    
    
                switch(this.modetype) {
    
    
                    case 'document':
                        this.fireEvent('documentsaved', form);
                        break;
    
    
                    case 'taskgroup':
                        this.fireEvent('taskgroupsaved', form);
                        break;
    
    
                }
    
    
    		}
    
    
    	}
    
    
    });
    this.down('maintenancewindowdocument').getForm().r eset(); does not reset the form fields. Lets say I load the window in 'Add' mode - the fields are all blank correctly, then I double click on an existing grid row - the fields are then populated with the grid row data, I then click 'Add' but now I get the fields holding on top the previous grid row data rather than being empty.

    If I uncomment the commented out code in red everything works!

    Any ideas ?

    Thanks in advance

  • #2
    I can't see anything immediately wrong. I would add some console.log code to verify that the switch for modetype and the if statement for the this.mode is going down the path you'd expect.

    Based on your comment about the commented code making it work, do you have anything happening in the before show of the maintenance window?

    Comment


    • #3
      Thanks for the quick reply but I think I have solved it - xtypes maintainwindowdocument and maintainwindowtaskgroup are both forms and had "trackResetOnLoad: true" set, removing this solved the problem.

      Comment

      Working...
      X