mercredi 30 avril 2014

Combo live search with SQL

search.png

Code:



...
{
xtype: 'panel',
region: 'west',
tbar: [{
xtype: 'combo',
id: 'searchCombo',
store: Ext.create('Ext.data.Store', {
id: 'searchStore',
model: Ext.define("SearchModel", {
extend: 'Ext.data.Model',
fields: ['id', 'name']
})
}),
triggerAction: 'query',
displayField: 'name',
triggerCls: 'x-form-search-trigger',
listConfig: {
loadingText: 'Searching...',
emptyText: 'user not found.',
// Custom rendering template for each item
getInnerTpl: function () {
return '<span>{name}</span>';
}
},
listeners: {
change: function (combo, newValue, oldValue, eOpts) {
if (newValue.trim().length == 3) {
searchUser(newValue); // sql table search
}
}
}
}
}
...


function returnedData(data) { // returned data: [{id: 'us001', name: 'Mücahid DANIŞ'}]
if (Ext.isArray(data)) {
for (var i = 0; i < data.length; i++) {
searchStore = Ext.data.StoreManager.lookup('searchStore');
searchStore.loadData(data);
}
}
}

data added to combo store but combobox not collapse Note: sql search with xmpp


Aucun commentaire:

Enregistrer un commentaire