views:

879

answers:

2

I have a ComboBox with a remote json store.

It lets the user type in 3+ characters, then queries, displays list and lets user select one option. When the user selects an option, it uses the Ext.data.Record associated to the selected option to populate other fields elsewhere in the form. This works correctly.

Now I want to be able to pre-populate the said fields, by using the functions that I've already written as part of the combo box. What I have come up with, is to add an "artificial record" to the ComboBox's store, and then force its selection - which would trigger all the right functions and populate the other fields etc..

What I have is this function inside of the ComboBox (I've created a custom one by extending ComboBox):

loadRecord : function( record ){
    var data = {
        "results":1,
        "rows":[
            record
        ]
    }

    this.store.loadData( data ); // I realize I could just use store.add() instead.

    alert( this.store.getCount() ); // returns 1, so the record is in

    // Here is where I'd need to make a call to select this record.
}

I've tried this.select() and this.selectByValue() but to no avail. Knowing the record is in the store, what is the right way to select it from code?

Thank you in advance.

A: 

How about this:

record = this.store.getAt(1);
rodrigoap
Hi there,Thanks for your answer. getAt() will give me back the record, but I already have the record. I need to trick the entire ComboBox into believing that the user has selected the said record. I have found a work-around that works in my specific case, but it's not too elegant, and I would still like to know whether there is a more general approach.Thanks again.
JuanD
+1  A: 

did you try combo.fireEvent('click', combo, record, index) ?

jujule