View Full Version : Populate a combobox using DirectStore

22 Mar 2010, 8:10 PM
I'm having issues while populating a combobox using DirectStore, the combobox is as follow:

this.Combo = new Ext.form.ComboBox({
fieldLabel: "Name",
editable: false,
triggerAction: 'all',
mode: 'remote',
store: new Ext.data.DirectStore({
reader: new Ext.data.JsonReader({
successProperty: 'success',
idProperty: 'name',
root: 'data',
fields: [ 'name' ]
autoLoad: true,
api: { read: SS.MyApi.getNames }
valueField: 'name',
displayField: 'name'

The returned json is:


And the c# code that generates the json

public JObject getNames()
List<string> names = new List<string>();

JObject data = new JObject();
data.Add(new JProperty("name", names));
return new JObject(
new JProperty("success", true),
new JProperty("data", data)

The combobox is showing only one entry with "name1,name2,name3". How can i have one entry per name?
Thanks in advance!

27 Apr 2010, 11:58 PM
Try change it to [{name:"name1"},{name:"name2"},{name:"name2"}]

7 Nov 2011, 2:37 AM
Thanks for combobox coding in proper format ! thanks for sharing dude !

Posted By Brady Chris,
provillus (http://www.provilluswarning.info/) | zquiet (http://www.zquietinfo.com/)