PDA

View Full Version : Question on Stopping Events



mmuoio
31 Jan 2013, 11:04 AM
Hi all. I have an editable grid. I'm trying to add functionality to it where if I have a row selected and I hit enter, it starts editing that row. I have that working fine by using addKeyMap on keyup on grid.getEl(). My problem is that I also want to be able to complete the edit using the enter key. Right now when I hit enter to end the edit, it immediately starts editing it again. I feel like this is a propagation issue but I haven't been able to figure out where to stop it. I've been trying in the column definition's editor config, but that doesn't seem to be the right place. I'm absolutely stumped, any ideas?

Here's the code I'm using to start editing:


grid.getEl().addKeyMap({
eventName: "keyup",
binding: [
{
key: Ext.EventObject.ENTER,
ctrl: false,
fn: function(e){
cellEditing.startEdit(grid.getSelectionModel().getSelection()[0], 1);
}
}
]
});



var columns = [{
text: '#',
width: 40,
sortable: false,
cls: 'headerBox',
dataIndex: 'answer_number'
},
{
text: 'Answer',
flex: 1,
sortable: false,
dataIndex: 'answer_text',
cls: 'headerBox',
editor: {
allowBlank: true,
xtype: 'textfield',
listeners: {
specialkey: function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
field.el.swallowEvent('keyup', true); //this isn't working
}
}
}
}
}
];

mmuoio
31 Jan 2013, 12:33 PM
Figured it out. I made the keymap into a variable and then used the .disable() and .enable() methods to turn it on/off as needed.