Databinding for ExtJs Combobox from Database(Sql)
How to bind d开发者_StackOverflow社区ata to ExtJS combo from sql database (how to assign datatable for extjs combobox as a store)
basic example should be like this:
var combo = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
store: new Ext.data.JsonStore({
reader: new Ext.data.JasonReader ( {
fields: [ 'myId', 'displayText' ],
root: 'rows'
}),
proxy: new Ext.data.HttpProxy ( {
url: 'path/to/your/script.aspx'
} )
valueField: 'myId',
displayField: 'displayText'
});
where /path/to/your/script.aspx returns data like this:
{"success":true,"total":4,"rows":[
{"myId":"1","displayText":"Option 1"},
{"myId":"2","displayText":"Option 2"},
{"myId":"3","displayText":"Option 3"},
{"myId":"4","displayText":"Option 4"}
]}
精彩评论