1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    40
    Vote Rating
    0
    psambhus is on a distinguished road

      0  

    Question Store valueField and displayField

    Store valueField and displayField


    Hi all ,

    i want to know the basic difference between the valueField and displayField in the store and how can i use them.
    any example would be appreciated.

    Thanks in advance .....

  2. #2
    Ext JS Premium Member
    Join Date
    Nov 2007
    Location
    Munich
    Posts
    30
    Vote Rating
    0
    sigaref is on a distinguished road

      0  

    Default


    I know valueField and displayField especially from comboboxes.

    You could have a combobox linked to the following data:

    [
    {countrycode: 'IT', countryname: 'Italy'},
    {countrycode: 'DE', countryname: 'Germany'},
    {countrycode: 'AT', countryname: 'Austria'},
    {countrycode: 'UK', countryname: 'United Kingdom'}
    ]

    In your combobox you have on field which should be display both in the dropdown and in the "no-dropdown" view. In this case the fieldname is "countryname", because you probably want the names Italy, Germany, ... to be visible, so when initializing the combobox you should specify displayField: "countryname".

    On the other hand you want to retrieve a value for the selected item, in this case probably it is better to work with the countrycode instead of the name, that means if you have selected "Italy" you want to get "IT" when calling the combobox's getValue() method. For this case set valueField: "countrycode".

Thread Participants: 1