Results 1 to 5 of 5

Thread: Dynamic TextArea

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    16
    Vote Rating
    0
      0  

    Default Dynamic TextArea

    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.

    Thanks,

  2. #2
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Vote Rating
    93
      0  

    Default

    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.

  3. #3
    Sencha User
    Join Date
    May 2013
    Posts
    7
    Vote Rating
    0
      0  

    Default 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.

  4. #4
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Vote Rating
    93
      0  

    Default

    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.

  5. #5
    Sencha User
    Join Date
    May 2013
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Thanks Colin for providing the understanding. I will write CSS and see if its work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •