PDA

View Full Version : edit grid field directly at cursor location



tuan43
12 Jan 2017, 12:37 PM
Hi,
I have a grid field that needs to be edited at the cursor location the user clicks in. Currently it defaults to the right of whatever content is in the field.


Ext.define('acme.corp.SomeCmp', {
extend: 'Ext.tree.Panel',
...,
columns: [{
dataIndex: 'foo',
itemId: 'fooId',
editor: {
xtype: 'numberfield',
allowExponential: false,
hideTrigger: true
}
}],
plugins: [{
ptype: 'cellediting',
clicksToEdit: 1,
listeners: {
beforeedit: function (editor, event) {
...
}
}
}]
});

Gary Schlosberg
13 Jan 2017, 3:31 PM
You should be able to do this with the selectText() method.
http://docs.sencha.com/extjs/6.2.1/classic/Ext.form.field.Number.html#method-selectText

Gary Schlosberg
13 Jan 2017, 3:32 PM
Oh sorry, I just saw you are using 4.x. I think that was added in 5.0.0.

tuan43
17 Jan 2017, 11:31 AM
Hi Gary,
Even if it was Ext 5, how would I know the text location based on the focus event?
I assume from focus event, I would then call this selectText fn

Thanks,
Tuan