jayarjo
jayarjo

Reputation: 16716

What is a proper way to load data into a form with comboboxes?

Sencha recommends to avoid manual loading of data into a form and use loadRecord instead. But if there are combos in the form, what happens is that valueField is inserted into the text area, instead of displayField. One would think that the associated store should be loaded first and then the loadRecord has to be invoked. But what is the proper way?

Upvotes: 1

Views: 99

Answers (2)

Saki
Saki

Reputation: 5856

loadRecord is a very simple function that takes values from the record fields and then calls setValue(recordFieldValue) on the corresponding form fields (where name of the record field matches name of the form field).

Hence, if the form field combo store is not loaded, or if recordFieldValue is not found in the store, then the raw value is just displayed in the text part of the combo.

You must assure that the combo store is loaded before you call load record.

Upvotes: 1

Dinkheller
Dinkheller

Reputation: 5054

you need to add the key "name" to each form field to have it working. Then you can add either a record to be loaded or to add data.

intialize: function() {
    var data = {
        nameOfComboItem: false, // validValue
        nameOfSecondComboItem: true
    };
    this.down('formpanel').setData(data);
}

Upvotes: 0

Related Questions