PDA

View Full Version : Urgent Help on Loading DB values to Json store



rxbass
17 Oct 2012, 11:18 PM
I need to load db values to a combo box for multi selection. I can't figure out, why values are not loading into combo box. By firebug, console.log values are printed out. Here is my code for multiselect combo box,



var groups = new Ext.data.JsonStore({
fields: [
{ id: 'id' },
{ name: 'name' }
],
root: 'rows',
autoDestroy: true,
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url : GO.settings.modules.schedule.url + 'groups.php',
}),
reader: {
type: 'json',
root: 'rows'
},
listeners: {
load: function(obj, records){
Ext.each(records, function(rec){
console.log(rec.get('name')); }); } } }); var taskGroup = new Ext.form.ComboBox({
name : 'Group',
hiddenName : 'group',
triggerAction : 'all',
editable : false,
fieldLabel : 'Group',
mode : 'local',
autoLoad: true,
displayField : 'text',
store : groups,
columns: [ { dataIndex: 'name' } ], });

sword-it
18 Oct 2012, 12:23 AM
Hi rxbass,



var groups = new Ext.data.JsonStore({ fields: [ { id: 'id' }, { name: 'name' } ],

Change fields config like -


fields: [{name: 'id'}, {name: 'name'}]


Add displayField and valueField config into your combobox, like-



xtype:'combo'
, hiddenName: 'sample'
, displayField:'name'
, valueField:'id'
.................

rxbass
18 Oct 2012, 1:15 AM
Perfect...Works fine.. for multiselect?