-
27 Apr 2011 11:24 PM #1
TextArea with wrap:off?
TextArea with wrap:off?
Something like this used to work in Ext JS 3:
But, not in Ext JS 4. Trading autoCreate with autoEl, which seems to be the new name for the same config option, results in some interesting disasters.Code:xtype: 'textareafield', autoCreate: { tag: 'textarea', spellcheck: 'false', wrap: 'off' },
Any ideas on how to allow the same functionality (injecting DOM attributes) in Ext JS 4?
-
29 Apr 2011 3:32 PM #2
After rummaging through the source code, I found this workaround. It actually seems like the old method is no longer supported, because fields are rendered using templates.
First, create a custom template for your textarea:
Then, to use it:Code:var noWrapTextAreaTpl = new Ext.XTemplate( '<textarea id="{id}" ', '<tpl if="name">name="{name}" </tpl>', '<tpl if="rows">rows="{rows}" </tpl>', '<tpl if="cols">cols="{cols}" </tpl>', '<tpl if="tabIdx">tabIndex="{tabIdx}" </tpl>', 'class="{fieldCls} {typeCls}" ', 'autocomplete="off" spellcheck="off" wrap="off">', '</textarea>', { compiled: true, disableFormats: true } );
Note that "fieldSubTpl" is undocumented! This does, however, work.Code:xtype: 'textareafield', fieldSubTpl: noWrapTextAreaTpl,
-
2 Oct 2012 4:11 PM #3
And now, here's the same fix for Ext JS 4.1:
Code:var noWrapTextAreaTpl = Ext.create('Ext.XTemplate', '<textarea id="{id}" ', '<tpl if="name"> name="{name}"</tpl>', '<tpl if="rows"> rows="{rows}"</tpl>', '<tpl if="cols"> cols="{cols}"</tpl>', '<tpl if="cols"> cols="{cols}"</tpl>', '<tpl if="placeholder"> placeholder="{placeholder}"</tpl>', '<tpl if="size"> size="{size}"</tpl>', '<tpl if="maxLength !== undefined"> maxlength="{maxLength}"</tpl>', '<tpl if="readOnly"> readonly="readonly"</tpl>', '<tpl if="disabled"> disabled="disabled"</tpl>', '<tpl if="tabIdx"> tabIndex="{tabIdx}"</tpl>', ' class="{fieldCls} {typeCls}" ', '<tpl if="fieldStyle"> style="{fieldStyle}"</tpl>', ' autocomplete="off" spellcheck="false" wrap="off">\n', '<tpl if="value">{[Ext.util.Format.htmlEncode(values.value)]}</tpl>', '</textarea>', { compiled: true, disableFormats: true } );
-
11 Feb 2013 5:36 AM #4
Awesome fix. Thank you.
Similar Threads
-
preventing word-wrap in textarea
By nokia786 in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 22 Nov 2012, 12:11 AM -
how to add wrap to textarea??
By vee.ant in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 9 Jul 2009, 4:20 AM -
Get TextArea to wrap in GXT
By mattdarnold in forum Ext GWT: Help & Discussion (1.x)Replies: 4Last Post: 16 Jun 2009, 5:17 AM -
Wrap long single word in a textarea
By RobSmith in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 10 Jan 2008, 5:17 AM


Reply With Quote