Results 1 to 2 of 2

Thread: Store valueField and displayField

  1. #1
    Ext User
    Join Date
    Apr 2008
    Vote Rating

    Question 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
    Vote Rating


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

Posting Permissions

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