PDA

View Full Version : [OPEN-1108] IE6 NumberField selectOnFocus



ciba1
7 Jul 2010, 6:28 AM
Greetings,

I am facing an issue with NumberField editor when I use selectOnFocus:true in the editor declaration for my edit-grid. I have given custom functionality to navigate in the grid using arrow keys. When I press UP/DOWN arrow keys in IE6, the number field does not select the text. It works fine if I change from NumberField to TextField. I have attached the updated edit-grid.js file for reference (Change extension from txt to js).

To replicate (only in IE6):
Use this file in edit-grid.html and load the grid. In the pricing column, navigate using arrow keys (Up and Down). As you will notice, the text is not always selected.
Now change the code in the js file to represent a TextField instead of a NumberField in the price column. Perform the same test. It selects the values always.

Please advice if there is anything wrong in my implementation or a workaround to this problem.

Thanks in advance.

Best Regards,
Urvi

jsakalos
7 Jul 2010, 7:00 AM
It looks like you've discovered a cross-browser compatibility bug. Should I move this thread to Bugs forum where it will be picked by the devel team?

Condor
7 Jul 2010, 7:09 AM
I had the same requirement. I solved it by writing my own onEditorKey method:

onEditorKey : function(field, e){
var k = e.getKey(),
newCell,
g = this.grid,
last = g.lastEdit,
ed = g.activeEditor,
ae, r, c;
var shift = e.shiftKey;
if(k == e.TAB){
e.stopEvent();
ed.completeEdit();
if(shift){
newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
}else{
newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
}
}else if(k == e.ENTER){
if(this.moveEditorOnEnter !== false){
if(shift){
newCell = g.walkCells(last.row - 1, last.col, -1, this.acceptsNav, this);
}else{
newCell = g.walkCells(last.row + 1, last.col, 1, this.acceptsNav, this);
}
}
}else if(k == e.UP){
e.stopEvent();
newCell = g.walkCells(last.row - 1, last.col, -1, this.acceptsNav, this);
if(newCell){
ed.completeEdit();
}
}else if(k == e.DOWN){
e.stopEvent();
newCell = g.walkCells(last.row + 1, last.col, 1, this.acceptsNav, this);
if(newCell){
ed.completeEdit();
}
}
if(newCell){
r = newCell[0];
c = newCell[1];
if(last.row != r){
this.selectRow(r);
}
if(g.isEditor && g.editing){
ae = g.activeEditor;
if(ae && ae.field.triggerBlur){
ae.field.triggerBlur();
}
}
g.startEditing(r, c);
}
},

ciba1
8 Jul 2010, 12:04 AM
Hi,

jsakalos, if it is a bug, then yes, please move it to the appropriate forum.

Condor, thanks for the code sample. For now, I changed NumberField to TextField and put a config property: maskRe: /[0-9]+/ to allow only integer values.

jsakalos
8 Jul 2010, 12:41 AM
Moved.