[CLOSED] [1.0] Multiline textfield and the note property - dynamic update of note

  1. #1

    [CLOSED] [1.0] Multiline textfield and the note property - dynamic update of note

    What do I need to do to get the note property of the ml textfield to update with each keystroke. I would like to use it as a max length counter that shows the max num of characters allowed along with the number of characters remaining (i.e. [20/140]).

    Here is a snippet from the javascript keystroke method I have now (txtBig = multiline textfield):
    var el1 = Ext.getCmp('txtBig');
     
    el1.note = "new note";
     
    alert(el1.note);
    The above code creates an alert box showing the new note value, but the note box on the cotrol is not updated. This seems like one of those "doLayout()" situations. What am I leaving out?:confused:

    Also, is there a way to move the note box from the bottom-left to the bottom-right?
    Last edited by geoffrey.mcgill; Jul 09, 2010 at 4:22 AM.
  2. #2
    Hi betamax,

    Just remember in the client API, you'll typically call getter/setter functions instead of directly setting the property. For example, you call .setValue() and .getValue() instead of set/get the .value property.

    To update the Note text, you can call the .setNote("Hello World!") function.

    The following sample demonstrates getting the count of the chars and updating the Note. You might have to play with the logic a bit.

    Example

    <ext:TextField ID="TextField1" runat="server" FieldLabel="Item 1" Note="&nbsp;" EnableKeyEvents="true">
        <Listeners>
            <KeyPress Handler="el.setNote('Count : ' + (el.getValue().length + 1));" />
        </Listeners>
    </ext:TextField>
    The "el" object is an instance of the TextField object.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    As well, you can reference a component by it's client-side id and should not require the extra .getCmp call.

    Based on your original sample, the following should work.

    Example

    txtBig.setNote("new note");
    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    We had tried getnote(). Should have maybe experimented a little longer.:)

    Thanks for the very fast reply

    mark as [CLOSED]

Similar Threads

  1. [CLOSED] Note Right Align
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 22, 2013, 1:59 PM
  2. [CLOSED] Note is always encoded
    By r_honey in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 23, 2011, 8:53 PM
  3. [CLOSED] CompositeField and Note
    By bethc in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 27, 2010, 12:41 PM
  4. [CLOSED] Note property not updated during AjaxEvent
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 19, 2009, 4:57 AM
  5. Replies: 3
    Last Post: Jul 14, 2009, 7:02 AM

Posting Permissions