1. #1
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Sesshomurai is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,167
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  3. #3
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Sesshomurai is on a distinguished road

      0  

    Default


    Here's a simple JSON I am using:
    Code:
    var jdata = {"peopleCount":"2","placeCount":"1","people":[ {"id":"1","name":"Jillian","concepts":[ { "concept":"Man" ,"concept":"Woman"}] } ]};
    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.

    Here's the store:
    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
    )
    });
    and column mode:
    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'
                })
            }
            ]);
    Rather than using the "concepts" list data index to build the combo, it just concatenates it into one string.
    Am I missing something?

    And thank you so much for the reply. You guys/gals are awesome!

    Sessh

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,167
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  5. #5
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Sesshomurai is on a distinguished road

      0  

    Default


    Ok, thanks. I added a separate store. The JSON looks the same with a list of dictionaries with an entry for the combobox.
    Code:
    "personConceptsCount": "1","personConcepts": [{"concept": "&%causes=", "id": 20}, {"concept": "&%result+", "id": 21}]
    In the column model, I refer to the Store that indexes to the above JSON list of dictionaries (personConcepts).
    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
    )
    });
    The column model column with combo:

    Code:
               header: "Concept",
               width: 130,
               editor: new Ext.form.ComboBox({
               		store: personConceptsStore,
               		displayField: 'concept',
                   listClass: 'x-combo-list-small'
                })
    But it doesn't display. When I double click the combo, I see a <div ...> style markup.

    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

Thread Participants: 1