2014-06-19 101 views
0

我創建了一個窗口小部件作爲面板中的幾個組件。我如何鏈接記錄參數與這些組件?extjs5 widgetcolumn單個單元格中的多個窗口小部件

例如:

{ 
    xtype: 'widgetcolumn', 
    dataIndex: 'data', 
    widget: { 
     xtype: 'panel', 
     height: 77, 
     width: 642, 
     layout: { 
      type: 'vbox', 
      align: 'stretch' 
     }, 
     items: [ 
      { 
       xtype: 'button', 
       text: record.get('name') //<<-- how can i link this record from the grid with this component? 
      }, 
      { 
       xtype: 'button', 
       text: record.get('type') //<<-- how can i link this record from the grid with this component? 
      }, 
      { 
       xtype: 'button', 
       text: record.get('location') //<<-- how can i link this record from the grid with this component? 
      } 
     ] 
    } 
} 

我有一個下列存儲:

var store = Ext.create('Ext.data.Store', { 
    fields:['name', 'type', 'location'], 
    data:[ 
      {name: 'name1', type: 'type1', location: 'loc1'}, 
      {name: 'name2', type: 'type2', location: 'loc2'} 
    ] 
}); 

也許,我可以通過渲染功能,訪問記錄?類似這樣的:

renderer: function(value, meta, record) { 
    //How can I get access to widget instance? 
} 

回答

1

我解決了這個問題。我們需要訪問父元素 - widgetcolumn,然後調用函數 - getWidgetRecord。

{ 
xtype: 'label', 
text: 'Some text...', 
cls: 'gridcall-label-asgmt', 
listeners: { 
    resize: function(label) { 
     var parent = label.up(); 
     while(typeof parent.up() !== 'undefined') { 
      parent = parent.up(); 
     } // --- while 

     var record = parent.getWidgetRecord(); 
     if (typeof record === 'undefined') return; 

     label.setText(record.data.asgmt, false); 
    } // --- resize 
} // --- listeners 

}

相關問題