PDA

View Full Version : Static Json data help



itlvk
31 Jul 2010, 2:05 AM
I have static json data:



var data = [{ Id: '1', Name: 'Assign' }, { Id: '2', Name: 'Reject' }, { Id: '3', Name: 'Feedback' }, { Id: '4', Name: 'Close'}];


how to set it to comboBox, please help, thanks

fay
31 Jul 2010, 2:13 AM
To test, modify the \examples\form\combos.js example:



var jsonData = [{ Id: '1', Name: 'Assign' }, { Id: '2', Name: 'Reject' }, { Id: '3', Name: 'Feedback' }, { Id: '4', Name: 'Close'}];

var store = new Ext.data.JsonStore({
fields: ['Id', 'Name'],
data: jsonData
});

var combo = new Ext.form.ComboBox({
store: store,
displayField: 'Name',
valueField: 'Id',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
applyTo: 'local-states'
});

itlvk
31 Jul 2010, 2:22 AM
work fine ! many thanks