4 Mar 2013 2:10 AM #1
Hi, We have one requirement to show TextArea height and width dynamically based on the text size.
Can anyone has idea on the this, please help.
4 Mar 2013 11:57 AM #2
For browsers which support it, TextArea has support (since GXT 3.0.1) for letting the user control the size - see https://developer.mozilla.org/en-US/docs/CSS/resize for more details on where this is supported and what this entails.
You could also use the TextMetrics class to measure a block of text to see how big you should size the TextArea. Controlling both height *and* width* could be tricky - a string without line breaks could be 10000px wide and only 25px tall, or could be 100px wide and 2500px tall, plus or minus word breaks. You'll need to set some constraints, or assume line breaks.
18 May 2013 11:01 PM #3
wrap off for textarea
wrap off for textarea
Textarea is wrapping off the line which I don't want. Instead I want a horizontal scroll bar I line exceeds textarea's width. I tried textarea.getElement().setAttribute("wrap","off") but its not working. Same is working for gwt's textarea.
Please suggest some solution.
19 May 2013 8:14 PM #4
I'm not sure what wrap=off is - based on https://developer.mozilla.org/en-US/...area#attr-wrap, off isn't a valid value, only soft or hard. Which browser are you expecting that to work in?
From http://stackoverflow.com/questions/6...-from-textarea it isn't supported, but you could be using CSS instead.
Finally, the GXT Textarea consists of more than just a <textarea> element (in order to make things like validation messages be drawn), so calling getElement() returns the 'wrong' element - the parent of the actual <textarea>. This means that you aren't setting that attribute on the correct element. Additionally, each time the value changes, the contents will be redrawn - the original html (the template in the appearance) must be modified or the setAttribute call must be run every time the widget re-renders. Note that properly written CSS should not have this issue.
20 May 2013 2:23 AM #5
Thanks Colin for providing the understanding. I will write CSS and see if its work.