2014-03-07 51 views
2

我想將一個按鈕添加到網格中,以便用戶可以通過傳入按鈕行中的值來查看給定任務的時間表條目值。網格加載得很好,直到我將該按鈕添加到columnCfgs。當按鈕在那裏,我得到一個「Uncaught TypeError:Object [object Object]沒有方法'setSortState'」錯誤。如何在網格上添加自定義按鈕並傳遞行值?

{text:'View Time', 
     xtype: 'button', 
     listeners: { 
      click: Ext.bind(this._viewTimeEntryValues(projectId, taskId), this) 
     } 
    }, 

滿格代碼:

this.grid = this.add({ 
    xtype: 'rallygrid', 
    model: model, 
    defaultSortToRank: true, 
    showRowActionsColumn: false, 
    columnCfgs: [ 
     {text:'View Time', 
      xtype: 'button', 
      listeners: { 
       click: Ext.bind(this._viewTimeEntryValues(projectId, taskId), this) 
      } 
     }, 
     {text:'Id',    dataIndex:'FormattedID'}, 
     {text:'Name',   dataIndex:'Name'}, 
     {text:'Project',  dataIndex:'Project'} 
    ], 
    storeConfig: { 
     context: { 
      projectScopeUp: false, 
      projectScopeDown: true 
     }, 
     filters: this._activeFilters 
    } 
}); 
  • 你如何添加自定義按鈕,一個網格?
  • 你如何傳遞按鈕行的值?

回答

2

我在代碼this github repo中使用了一個按鈕。這裏是一個按鈕的網格:

var g = Ext.create('Rally.ui.grid.Grid', { 
    id: 'g', 
    store: store, 
    enableRanking: true, 
    columnCfgs: [ 
      {text: 'Formatted ID', dataIndex: 'FormattedID'}, 
      {text: 'Name', dataIndex: 'Name'}, 
      {text: 'State', dataIndex: 'State'}, 
      {text: 'Last Revision', 
      renderer: function (v, m, r) { 
       var id = Ext.id(); 
       Ext.defer(function() { 
        Ext.widget('button', { 
         renderTo: id, 
         text: 'see', 
         width: 50, 
         handler: function() { 
          that._getRevisionHistory(data, r.data); 
         } 
        }); 
       }, 50); 
      return Ext.String.format('<div id="{0}"></div>', id); 
      } 

     } 
    ], 
    height: 400, 
}); 
+0

謝謝你!那就是我一直在尋找的! –

+0

不客氣 – nickm

相關問題