-
7 Nov 2008 12:31 AM #1
preventing word-wrap in textarea
preventing word-wrap in textarea
I have the below configuration for a textarea, while the vertical scrollbars appear as the text increases, the horizontal scrollbar does not appear as the length of a sentence increases. I do not want the word wrapping and want it to horizontally scroll. Searching documentation and forums did not help.
Is there something very common that I am missing here?Code:{ xtype: 'textarea', name: 'inputText', colspan: 3, height: 300, width: 400, allowBlank: false }
-
7 Nov 2008 4:55 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
I don't believe you can. Implementation of textarea differs between browsers. For instance, Fx does not word wrap while IE6/7 do.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
18 Mar 2009 8:51 AM #3
WordWrap in TextArea
WordWrap in TextArea
TextArea onRender
Code:wordWrap: false; ... this.el.setOverflow('auto'); if (this.wordWrap === false) { if (!Ext.isIE) { this.el.set({wrap:'off'}) } else { this.el.dom.wrap = "off"; } } if (this.preventScrollbars === true) { this.el.setStyle("overflow", "hidden"); }
-
18 Mar 2009 9:41 AM #4
-
6 Oct 2009 4:33 PM #5
works for me!
works for me!
Based on the post above and this post I've created the following override to extend the TextArea and add the wordWrap option which seems to work fine for me. But so I'm putting it out there for anyone else to use and or comment on...
Code:Ext.override(Ext.form.TextArea, { initComponent: Ext.form.TextArea.prototype.initComponent.createSequence(function() { Ext.applyIf(this, {wordWrap: true}); }), onRender: Ext.form.TextArea.prototype.onRender.createSequence(function(ct, position){ this.el.setOverflow('auto'); if (this.wordWrap === false) { if (!Ext.isIE) { this.el.set({wrap:'off'}) } else { this.el.dom.wrap = 'off'; } } if (this.preventScrollbars === true) { this.el.setStyle('overflow', 'hidden'); } }) });
-
21 Nov 2012 11:42 PM #6
Solution(For Ext 4 and above) would be
textarea.inputEl.dom.wrap = "off";
and for earlier versions
textarea.el.dom.wrap = "off";
Write this in the after render listener of text area .it should work.
best of luck
-
22 Nov 2012 12:11 AM #7
Thanks a lot Jagadeesha
It Works 


Reply With Quote