• 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.

Stop event from firing

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

  • Stop event from firing

    I have a grid using the rowediting plugin.
    Code:
    Ext.define('WarehouseInventoryMaintenance.view.ItemCountGrid', {
    	extend : 'Ext.grid.Panel',
    	alias : 'widget.itemcountgrid',
    
    	header : false,
    	title : 'My Grid Panel',
    	store : 'Details',
    	emptyText : 'No Items Loaded To Display',
    	sortableColumns : false,
    
    	initComponent : function() {
    		var me = this;
    
    		Ext.applyIf(me, {
    			columns : [{
    				xtype : 'numbercolumn',
    				format : '0',
    				dataIndex : 'D1ITEMNBR',
    				align : 'center',
    				menuDisabled : true,
    				editor : {
    					xtype : 'numberfield',
    					hideTrigger : true,
                                            keyNavEnabled: false,
    					selectOnFocus : true,
    					maxLength: 9,
    					enforceMaxLength: true
    				},
    				header : 'Item'
    			}, {
    				xtype : 'numbercolumn',
    				format : '0',
    				dataIndex : 'D1LOTCDDAT',
    				name: 'D1LOTCDDAT',
    				align : 'center',
    				menuDisabled : true,
    				text : 'Lot Code'
    			}, {
    				xtype : 'numbercolumn',
    				format : '0',
    				dataIndex : 'D1CASES',
    				align : 'center',
    				menuDisabled : true,
    				editor : {
    					xtype : 'numberfield',
    					hideTrigger : true,
                                            keyNavEnabled: false,
    					selectOnFocus : true,
    					maxLength: 7,
    					enforceMaxLength: true,
    					minValue: 0
    				},
    				text : 'Cases'
    			}, {
    				xtype : 'gridcolumn',
    				dataIndex : 'D1CASEUPC',
    				align : 'center',
    				menuDisabled : true,
    				text : 'Case UPC'
    			}, {
    				xtype : 'numbercolumn',
    				format : '0',
    				dataIndex : 'D1SBC',
    				align : 'center',
    				menuDisabled : true,
    				text : 'Units Per Case'
    			}, {
    				xtype : 'numbercolumn',
    				format : '0',
    				dataIndex : 'D1ITCNT',
    				align : 'center',
    				menuDisabled : true,
    				text : 'Cases Per<br />Warehouse Box'
    			}],
    			viewConfig : {
    				markDirty : false
    			},
    			plugins : [Ext.create('Ext.grid.plugin.RowEditing', {
    				clicksToEdit : 1,
    				autoCancel : false,
    				pluginId : 'rowediting'
    			})],
    			dockedItems : [{
    				xtype : 'toolbar',
    				dock : 'top',
    				items : [{
    					xtype : 'button',
    					disabled : true,
    					iconCls : 'add',
    					text : 'Add',
    					itemId : 'btnAddItem'
    				}, {
    					xtype : 'tbspacer'
    				}, {
    					xtype : 'tbseparator'
    				}]
    			}]
    		});
    
    		me.callParent(arguments);
    	}
    });
    On the grid I am listening for events edit, canceledit, itemcontextmenu, and selectionchange.
    Code:
        init: function (application) {
            var me = this;
            me.control({
                'itemcountgrid toolbar #btnAddItem': {
                    click: me.onClickAddItem
                },
                'gridcontextmenu #menuItemClear': {
                    click: me.onClickMenuItemClear
                },
                'itemcountgrid': {
                    edit: function (editor, e, eOpts) {
                        console.log('edit fired');
                        var record = e.record,
                            status = e.record.get('D1STATUS'),
                            rowIndex = e.rowIdx,
                            store = e.store,
                            itemCountGrid = e.grid,
                            originalValues = e.originalValues,
                            itemNumber = e.record.get('D1ITEMNBR');
                        console.log(status);
                        if (status === 'Add') {
                            if (!itemNumber || itemNumber === 0) {
                                me.onCancelItemEdit(editor, e, eOpts);
                            } else {
                                me.onAfterItemEditAdd(record, rowIndex, store, itemCountGrid, originalValues);
                            }
                        } else {
                            me.onAfterItemEditUpdate(record, rowIndex, store, itemCountGrid, originalValues);
                        }
                    },
                    canceledit: me.onCancelItemEdit,
                    itemcontextmenu: me.showGridContextMenu,
                    selectionchange: me.onGridSelectionChange
                }
            });
        },
    When selectionchange fires, I am executing the following code.
    Code:
        onGridSelectionChange: function(model, data, eOpts) {
            console.log(data);
            console.log(model);
            console.log('grid selection change fired');
            var me = this,
                store = model.store,
                record = store.getAt(0),
                itemNumber = "",
                status = data[0].get('D1STATUS'),
                itemCountGrid = Ext.ComponentQuery.query('itemcountgrid')[0];
                console.log(status);
            if (status === 'Update') {
                if (!Ext.isEmpty(record)) {
                    itemNumber = record.get('D1ITEMNBR');
                    if (itemNumber === "") {
                        store.removeAt(0);
                    }
                }
            }
        }
    The line "store.removeAt(0);" is causing the canceledit event to fire, I want to remove or disable this event from firing. I've spent several hours researching how to code this and cannot come up with a resolution. Any assistance would be appreciated.

  • #2
    Hmmm, if you are in an edit, and change to another row, that would also cause the canceledit to fire for the previous row. Are you sure the timing indicates that is not the case?

    I have other ideas or questions, but can you explain what you want to happen on the selectionchange event?

    It looks like you want it to sometimes remove the first record of the store? Why do you want this?

    Again, please share more about what you are trying to do.

    Comment

    Working...
    X