-
28 Jul 2008 6:14 PM #1
YACIGQ: Yet Another Combox In Grid Question
YACIGQ: Yet Another Combox In Grid Question
Hi,
I read all the previous posts/threads about ComboBox's used in Grids. It seems quite difficult. I have my basic JSON coming in from a store for my simple 2-column ColumnModel (1 textfield, 1 combo). I was hoping the field for the Combox column could be a simple array of values in the JSON. Has anyone written a column model that has a single store that the combobox column can use? I don't want to have a separate store for the combobox since it is already defined in a column model and indexing into another store per row would be rather difficult.
I saw the checkbox plugin, etc. A bit too advanced for me so far.
Sessh
-
28 Jul 2008 6:21 PM #2
There's nothing really special you need to do. Declare the store, then have the appropriate combos use it.
This assumes you've got a local store and aren't doing any tricky filtering.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
28 Jul 2008 7:15 PM #3
Here's a simple JSON I am using:
the column model has two columns. 1st is "name", 2nd is "concepts", which is a list to be used by the combobox, but it doesn't seem to read the list and make the menu. I'm not sure if its supposed to work that way, but seems intuitive if it would.Code:var jdata = {"peopleCount":"2","placeCount":"1","people":[ {"id":"1","name":"Jillian","concepts":[ { "concept":"Man" ,"concept":"Woman"}] } ]};
Here's the store:
and column mode:Code:var actionStore = new Ext.data.Store({ proxy: new Ext.data.MemoryProxy(jdata), reader: new Ext.data.JsonReader({ root: 'people', totalProperty: 'peopleCount', id: 'id'} , results ) });
Rather than using the "concepts" list data index to build the combo, it just concatenates it into one string.Code:var cm = new Ext.grid.ColumnModel([{ header: "Name", dataIndex: 'name', width: 110 },{ header: "Concept", dataIndex: 'concepts', width: 130, editor: new Ext.form.ComboBox({ lazyRender:true, listClass: 'x-combo-list-small' }) } ]);
Am I missing something?
And thank you so much for the reply. You guys/gals are awesome!
Sessh
-
28 Jul 2008 7:23 PM #4
The combo box has to be backed by a store of it's own.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
29 Jul 2008 4:18 AM #5
Ok, thanks. I added a separate store. The JSON looks the same with a list of dictionaries with an entry for the combobox.
In the column model, I refer to the Store that indexes to the above JSON list of dictionaries (personConcepts).Code:"personConceptsCount": "1","personConcepts": [{"concept": "&%causes=", "id": 20}, {"concept": "&%result+", "id": 21}]
The column model column with combo:Code:var personConceptsStore = new Ext.data.Store({ proxy: new Ext.data.MemoryProxy(jdata), reader: new Ext.data.JsonReader({ root: 'personConcepts', totalProperty: 'personConceptsCount', id: 'id'} , results ) });
But it doesn't display. When I double click the combo, I see a <div ...> style markup.Code:header: "Concept", width: 130, editor: new Ext.form.ComboBox({ store: personConceptsStore, displayField: 'concept', listClass: 'x-combo-list-small' })
In looking at the combo examples, none use a strict JSON that I could find, so I'm not sure how to format the JSON. I thought it was similar to how the grid rows were formatted (i.e. "id":id,"name":value).
How should the JSON look for the combo to work?
thank you so much,
Sessh


Reply With Quote