Results 1 to 2 of 2

Thread: How to set value for a combobox bound to a store?

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    39
    Vote Rating
    0
      0  

    Default How to set value for a combobox bound to a store?

    Hello
    i have a combobox that contains the list of my app's user declared as follows:

    xtype:'combobox',
    fieldLabel: 'Username',
    name: 'id_user',
    displayField:'name',
    valueField:'id_user',
    store: UsersStore

    I display the username and send the id to the database; the problem is that i don't know how to set the value when selecting from the db. If i do
    myForm.getForm().findField("id_user").setValue(record.data.id_user);

    I see the id and can't see the correct displayName ... how can i assign the pair id/name to the combo so that it displays the name and sends the id?
    Thanks in advance !

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Vote Rating
    391
      0  

    Default

    setValue should work. If it can't find the value in the store it will just show it in the combobox. Double check that the value you are setting is present in the field id_user in one of the records in your store. Make sure it's a perfect match, including case-sensitivity and data-type (string, number, etc.).

Posting Permissions

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