PDA

View Full Version : EditorGrid with TextArea: Enter Key Behavior



aserron
25 Apr 2011, 10:40 AM
Hi,
I want to get the same Excel like Enter Key behavior in the EditorGrid Panel.

This means:

Enter edit next row
Enter + Alt: add new line


The closer attempt was implementing RowSel Model and working with key up listener in the grid to start editing when you press enter.

Yet I was unable to switch Enter key response.

When I press enter I enter a new line in the text area.

My goal is to add new line by pressing Enter + Alt, and editing next cell when pressing Enter alone.

I tried suggestions made in this post
http://www.sencha.com/forum/archive/index.php/t-2947.html
Without any success.
Thanks in advance.

varunach
25 Apr 2011, 11:32 AM
check out KeyNav and attach it to the grid's afterrender listener

aserron
26 Apr 2011, 2:07 PM
Thanks for your tip.

Ext.NavKey seems to work for actions like startEditing, walking cells, etc.

This will resolve the problem of transform the enter key into a "edit next row" action.
I already achieve that with some GridView overrides.

The problem i could not address is adding a new line when pressing "ctrl + enter", in short i was able to handle navigation and editor behaviors but i couldn't add a new line with some other key rather than flat enter key.

hope you got some tip.

varunach
26 Apr 2011, 10:10 PM
var map = new Ext.KeyMap("my-element", {
ctrl : true,
key: 13, // or Ext.EventObject.ENTER
fn: myHandler,
scope: myObject
});

aserron
29 Apr 2011, 7:47 AM
var map = new Ext.KeyMap("my-element", {
ctrl : true,
key: 13, // or Ext.EventObject.ENTER
fn: myHandler,
scope: myObject
});

Looks good, seems to tap in the input, but still i cant make it work, i let my code below.



col = this.getColumnModel().getColumnAt(4);

col.editor.on({
scope : this,
render: function(cmp){
var t = cmp.el;
var map = new Ext.KeyMap(t, {
ctrl : true,
key : Ext.EventObject.ENTER , // or Ext.EventObject.ENTER
fn : function(){
console.log('key enter call back ',arguments)
},
scope : this
})
}
})


also question

1) How can i return another input like "shift + enter" as callback and prevent enter to be taken below.