PDA

View Full Version : textfield selected text



tdikarim
31 Aug 2012, 3:28 AM
Hi all,

extjs 4.1.1
How to get the selected text in a textfield or textarea ?


Thanks

Karim

sword-it
31 Aug 2012, 3:32 AM
HI!

i guess you want to get value for your textfield/textarea.

use yourField.getValue()

check this:-
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Text-method-getValue

Zdeno
31 Aug 2012, 3:33 AM
I think he needs following functionality:

http://www.sencha.com/forum/showthread.php?83407-TextField-Manipulating-the-selection-and-getting-the-selected-text-in-ExtJS-2
(http://www.sencha.com/forum/showthread.php?83407-TextField-Manipulating-the-selection-and-getting-the-selected-text-in-ExtJS-2)This post is a bit old but you can override it to Ext4.

tdikarim
31 Aug 2012, 6:34 AM
Hi zdeno,

I have already test this thread. But I have always null value returned.

dom.id is the id of my textfield
Ext.getCmp(dom.id).getSelectedText();

If you have another idea ...

Thanks

Zdeno
31 Aug 2012, 7:42 AM
In Ext4 you can get http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.TextArea dom element by:


var domElement = this.inputEl.dom; Then you can get selection range by

domElement.selectionEnd
domElement.selectionStart

I didnt test IE part but it could be pretty simple