2012-01-31 68 views
0

我想将一些ExtJS 3.3转换为4.0。 在ExtJS 3.x中,我可以创建一个带有独特组件ID的组合框,以后我可以使用Ext.getCmp(Id)来获取该组合框编辑器,以便我可以添加过滤器或者使用组合框本身。Extjs4 itemId,如何找回组合框列编辑器

现在,如果我指定一个Id,网格不会在网格中呈现组合框正确,他们说我必须使用itemId,然后实际上它的工作原理,我的意思是组合正确呈现在网格上,但然后我没有办法使用itemId来获取组合框本身。我试过grid.getComponent(itemId),grid.headerCt.getComponent(),我不得不说这个itemId有什么好处,我该怎么得到这个编辑器。

grid.columns集合具有用于简单字段(如文本,数字)的编辑器,对于组合框,它具有要求数据记录作为参数的getEditor。

我不得不再说一遍wtf,ExtJS 3.x是如此的错误,以至于他们觉得自己像修复它一样。

真的,这次升级让我去了很多次跆拳道......也许是我的错,但跆拳道...反正。

{ 
    header: 'Ürün/Hizmet', 
    width: 90, 
    dataIndex: 'AlinanHizmetId', 
    editor: { 
     itemId: 'AlinanHizmetId', 
     xtype: 'combobox', 
     allowBlank: false, 
     selectOnFocus: true, 
     valueField: 'Id', 
     displayField: 'HizmetAd', 
     triggerAction: 'all', 
     typeAhead: false, 
     forceSelection: true, 
     lazyRender: true, 
     minChars: '2', 
     listWidth: 300, 
     store: Ext.create('Ext.data.Store', { 
      storeId: '', 
      fields: [{ 
       name: 'HizmetTipAd', 
       caption: 'Hizmet Tip Adı', 
       type: Ext.data.Types.STRING, 
       clrType: 'String' 
      }, { 
       name: 'Id', 
       caption: 'Id', 
       type: Ext.data.Types.STRING, 
       clrType: 'Guid' 
      }, { 
       name: 'HizmetTip', 
       caption: 'HizmetTip', 
       type: Ext.data.Types.STRING, 
       clrType: 'String' 
      }, { 
       name: 'HizmetKod', 
       caption: 'Hizmet Kodu', 
       type: Ext.data.Types.STRING, 
       clrType: 'String' 
      }, { 
       name: 'HizmetAd', 
       caption: 'Hizmet Adı', 
       type: Ext.data.Types.STRING, 
       clrType: 'String' 
      }, { 
       name: 'Aciklama', 
       caption: 'Açıklama', 
       type: Ext.data.Types.STRING, 
       clrType: 'String' 
      }], 
      autoDestroy: false, 
      autoLoad: true, 
      autoSave: false, 
      sortInfo: { 
       field: 'HizmetAd', 
       direction: 'ASC' 
      }, 
      restful: false, 
      proxy: { 
       type: 'ajax', 
       actionMethods: { 
        read: 'POST' 
       }, 
       url: '/Yol/Combo/AlinanHizmet', 
       reader: { 
        type: 'json', 
        root: 'data', 
        idProperty: 'Id', 
        totalProperty: 'rowCount', 
        successProperty: 'success', 
        messageProperty: 'message' 
       } 
      }, 
      data: [] 
     }) 
    }, 
    filter: { 
     xtype: 'textfield' 
    }, 
    renderer: function (value, metaData, record, rowIndex, colIndex, store) { 
     return record.get('HizmetAd'); 
    } 
} 
+0

你试过'Ext.ComponentQuery'吗?尝试'grid.query('#item_id')'。 – Krzysztof 2012-01-31 09:21:33

+0

是的,它返回空数组。 “[]” – hazimdikenli 2012-01-31 09:29:14

+0

你能发布源代码吗? – Krzysztof 2012-01-31 10:00:29

回答

0
mygrid.on('beforeedit', function(e){ 
    if(e.field == 'ProductId') { 
     var gridCols = Ext.getCmp('my_grid').columns; 
     for(i = 0; i < gridCols.length; i++) 
      if (gridCols[i].dataIndex == 'ProductId') break; 
     var combo = gridCols[i].getEditor(e.record); 
    ... 

所以实际上column.getEditor(null)有窍门。

+0

我不知道列是混合集合还是其他数组,所以我在那里有for循环。 – hazimdikenli 2012-03-26 12:06:18

0

这是旧的 - 但你有没有试过grid.down('#item_id')