cansadadeserfeliz
cansadadeserfeliz

Reputation: 3133

ExtJs Add empty value to combobox which is loaded remotely?

I there any way to add an empty value to combobox which is loaded remotely?

{
    xtype: 'combobox',
    emptyText: 'Proveedor...',
    store: 'MyStore',
    displayField: 'title',
    valueField: 'mymodel_id',
    queryMode: 'remote',
    typeAhead: true
}

Upvotes: 1

Views: 3037

Answers (1)

Ye Liu
Ye Liu

Reputation: 8976

Listen to the load event of the store for the combobox, and insert an empty record in the handler:

Ext.getStore('MyStore').on('load', function(store) {
    store.insert(0, Ext.create('MyModel', {
        mymodel_id: -1,                  // some invalid id
        title: 'Choose from the list...' // default text for the empty record
    });
});

Upvotes: 4

Related Questions