1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    40
    Vote Rating
    0
    Suma is on a distinguished road

      0  

    Default How to get value from TextField in FlexTable

    How to get value from TextField in FlexTable


    Hi,
    I have a FlexTable and Two buttons(Add, Save). When i click on Add button a row containing a widget TextField is added into FlexTable. When i click on the Save button i want to retrieve the value which is typed in TextField. Kindly help me solving this problem.

  2. #2
    Ext GWT Premium Member
    Join Date
    Apr 2009
    Location
    NYC
    Posts
    111
    Vote Rating
    1
    stan229 is on a distinguished road

      0  

    Default


    Keep a reference to the text field and call field.getValue()

  3. #3
    Ext User
    Join Date
    Mar 2009
    Posts
    40
    Vote Rating
    0
    Suma is on a distinguished road

      0  

    Default


    But i want to add TextField whenever i click the Add button. How to keep reference of so many TextFields??

  4. #4
    Ext GWT Premium Member
    Join Date
    Apr 2009
    Location
    NYC
    Posts
    111
    Vote Rating
    1
    stan229 is on a distinguished road

      0  

    Default


    java.util.List<TextField>

  5. #5
    Ext User Ercaran's Avatar
    Join Date
    Dec 2008
    Posts
    9
    Vote Rating
    0
    Ercaran is on a distinguished road

      0  

    Default


    Hi Suma, I had the same need as you, and I've solved it in two different manners:

    1) you can assign a sort of "numerable" id:
    Code:
    id: 'textfield'+i,
    where "i" is an index growing with the number of iterations.
    In this way you'll have textfield1, textfield2...and you can use getComponent() specifing the id.

    2)the problem of the 1)solution is that if you want also to delete dynamically your field, you will get "undefined" results (eg if you have deleted textfield2, the getComponent("textfield2") will return you undefined, stopping your function). So you can get your fields by index: you get the main container,I think your is FlexTable, and then you search for its childs:

    Code:
    ft = Ext.getCmp("flextable-id");
    my_field_value = ft.getComponent(0).getValue();
    They're just suggestion, maybe you have to change them to fit your application. Hope it helps!

Thread Participants: 2