PDA

View Full Version : When celleditor is set to selectOnFocus, how can I deselect the text if needed?



Patrick Bennett
21 Mar 2014, 1:51 PM
Hello,

I have modified my grid to have a cellkeydown that handles when you are not in edit mode and the user types minus, period, or any number. I am doing a startEdit() but in this case I want to clear the contents of the cell, put the symbol they typed into the edit box and allow them to continue typing after that. What happens when you have selectOnFocus is that you can put the text in there, but it becomes selected automatically and any further key presses replace that text.

I still want to have the selectOnFocus behavior for any other time I do startEdit() though.

Here's the code:



if ((intKey >= e.ZERO && intKey <= e.NINE) || intKey == 45 || intKey == 173 || intKey == 109 || intKey == 110 || intKey == 190 || (intKey >= 96 && intKey <= 105)) {

var objSelectionModel = tableview.ownerCt.getSelectionModel(),

objEditor = tableview.ownerCt.getPlugin('celleditingplugin'),

objPos = objSelectionModel.getCurrentPosition();

objEditor.startEditByPosition(objPos);

objEditor.activeEditor.field.setRawValue(String.fromCharCode(intKey));

}