Results 1 to 2 of 2

Thread: Combobox with default value

  1. #1
    Ext User
    Join Date
    Sep 2007
    Vote Rating

    Default Combobox with default value

    I am adding a combobox to a fieldset

    			items :[{
    				xtype: 'combo',
    				fieldLabel: 'Address',
    				hiddenName: 'shipment-' + number + '-addr',
    			    store: addrStore,
    			    tpl: resultTpl,
    			    triggerAction: 'all',
    			    value: addressId,
    			    emptyText:'Select an address...',
    it get the adresses from a store that gets its data using a DWRProxy, it uses XTemplate to display a nice list of the adresses and when i post the form, the 'id' of the address gets posted. All that is working as intended.

    The problem i have is when i want to set the value, (the address has been chosen before), i know the 'id' and its stored in variable 'addressId', so i thought i could use

    value: addressId,
    but that sets the numerical id to the displayField instead of the 'friendly' value from the corresponding record. (but these records are not loaded yet, the store gets filled when you hit the trigger ...)

    what is the best solution for this ?

  2. #2
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    "A Land Down Under"
    Vote Rating


    The best solution that I can think of for this would be to not set the value before the store is loaded as you are trying to do there. As you've found, that doesn't work if the records aren't loaded yet.

    I'd set up a listener for the 'load' event of the store that check what the current selection is (that should be 'addressId' in your case) and sets that whenever the store is loaded. That way you can still get the value in there and you aren't left with this strange number that no one will recognise in there beforehand.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

Posting Permissions

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