2017-07-19 26 views
0

如果我使用「rallygrid」我可以像下面創建自定義列:無法創建「rallytreegrid」自定義(虛擬)字段,但可以在「rallygrid」

xtype: 'rallygrid', 
columnCfgs: [ 
    'FormattedID', 
    'Name', 
    { 
    text: 'Custom Value', 
    renderer: function(value, meta, record) { 
     return myArray[record.data.FormattedID].myValue; 
     } 
    }], 
context: this.getContext(), 
enableBulkEdit: true, 
showRowActionsColumn: true, 
storeConfig: { 
    model: 'PortfolioItem/Feature', 
    pageSize: 25 
} 

當我這樣做,我的'自定義價值'做我想要的。萬歲!

但是,如果我有一個像下面「rallytreegrid」替換此,它的錯誤:

Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({ 
    models: ['portfolioItem/feature'], 
    autoLoad: true, 
    enableHierarchy: true 
}).then({ 
    success: this._onStoreBuilt, 
    scope: this 
}); 

_onStoreBuilt: function(store) { 
    this.add({ 
        xtype: 'rallytreegrid', 
        store: store, 
        context: this.getContext(), 
        enableEditing: true, 
        shouldShowRowActionsColumn: true, 
        enableBulkEdit: true, 
        enableRanking: false, 
        columnCfgs: [ 
         'FormattedID', 
         'Name', 
         { text: 'Custom Value' } 
        ] 
       }); 
} 

因爲那自定義值「字段中出現錯誤,甚至有或沒有渲染的一部分。

Error: success callback for Deferred transformed result of Deferred transformed result of Deferred transformed result of Deferred threw: TypeError: Unable to get property 'substring' of undefined or null reference 

如果我刪除'自定義值'字段,它的工作原理是隆重的。

我在做什麼錯?

回答

1

我希望我對你有一個很好的答案 - 這看起來像一個錯誤。幸運的是,解決這個問題很簡單,只需要爲該列添加xtype即可。常規網格必須正確地默認這個,而treegrid不是。

{ 
    xtype: 'gridcolumn', 
    text: 'Custom Value', 
    renderer: function(value, meta, record) { 
     return 'rendered output goes here'; 
    } 
} 
+0

完美。以爲我瘋了,但謝謝你。一個簡單的解決方法。我應該想到這一點。 – user1910714