1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default change the list content of a combobox in EditorGrid

    change the list content of a combobox in EditorGrid


    An EditorGrid has a column filled with combobox
    Code:
    _this.filterGrid = new Ext.grid.EditorGridPanel({
        ....
        cm : new Ext.grid.ColumnModel([{
        header : "cmb",
        dataIndex : 'cmb',
        editor : new Ext.form.ComboBox({
         mode : 'local',
         displayField : 'cmb',
         triggerAction : 'all',
         store : new Ext.data.SimpleStore({
          fields : ['cmb']
         })
        })
       },
    now the combobox dinamically change it's list when i click the row,
    if the rowNumber is Singular, the combo will popup
    'Singular 1'
    'Singular 2'
    if the rowNumber is dual, the combo will popup
    'dual 1'
    'dual 2'

    how to make it changable?
    Thanks.

  2. #2
    Sencha User BitPoet's Avatar
    Join Date
    Sep 2008
    Location
    Bavaria
    Posts
    277
    Vote Rating
    1
    BitPoet is on a distinguished road

      0  

    Default


    Do you mean 'combobox' instead of 'checkbox'? And what do you mean by 'singular' and 'dual'? Please be a bit more verbose, or best of all, give us a short, working piece of code that we can drop into the local examples folder in extjs.

    If you mean to change the item text in the combo according to whether the rowNumber property in the record has one or more digits (I'm just doing wild guessing here), you could use a custom template with conditional logic:
    Code:
      editor: new Ext.form.ComboBox({
        ...combo config...,
        tpl: '<tpl for="."><div class="x-combo-list-item">{[values.rowNumber < 10 ? "Singular" : "dual"]} {chk}</div></tpl>',
       ...combo config...
      })

  3. #3
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    Oh I'm sorry, I miss typed... I mean the ComboBox...
    Thank you BitPoet, I tried your code, click on the combo but nothing happened.

    I didn't describe clearly, if the editorGrid.store has 3 records, then I click on first line, the combo's dropdown list should show:
    'singular 1'
    'singular 2'

    then I click on the second line, it should show:
    'dual 1'
    'dual 2'

    the third line should be same as the first line

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You should fill the store of the combobox in the beforeedit event of the EditorGridPanel (or in the beforestartedit event of the GridEditor).

  5. #5
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    how can i get the comboboxes in the EditorGridPanel ?
    when i click first row, how to get the first row's combobox?

    in ext2.2, i use:
    Code:
    grid.colModel.config[0].editor.field.store.loadData([['='], ['in'], ['like']]);
    but in ext3.0, how to do that..

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    The preferred way in both Ext 2 and 3 is:
    Code:
    grid.getColumnModel().getCellEditor(col, row).field.store.loadData([['='], ['in'], ['like']]);

  7. #7
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    it works~ thanks Condor.

Thread Participants: 2