2017-02-20 39 views
1

當我試圖重新下透視表與AG-電網使用floatingBottomRowData。所以一對值重複: enter image description hereAG網: <a href="https://i.stack.imgur.com/U07aB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U07aB.png" alt="enter image description here"></a></p> <p>使用floatingBottomRowData我不能找到一種方式來傳遞的價值觀所有生成列:樞軸

我的目標是訪問浮動行的每個單元格的列組值。 現在我無法分辨列組之間的差異(導致重複值)。

有什麼辦法可以區分不同的(col1,col2)對嗎?

回答

2

這是在銀網論壇給出的答案是:

得到樞軸鍵,這樣做:

floatingCellRenderer: function(params) { 
     if (gridOptions.columnApi.isPivotMode()) { 
      console.log(params.column.getId()); 
      var parent = params.column.getParent(); 
      if (parent) { 
       var pivotKey = console.log(parent.getOriginalColumnGroup().getColGroupDef().pivotKeys[0]); 
      }  
     } 
    } 

獲得在活動樞紐的列,使用列API ,例如columnApi.getPivotColumns(),它將返回一個pivot列的列表。這將是有序的,所以如果你有很多列,你會遍歷每個父母。

+0

你有沒有想過如何setPinnedBottomRowData pivoting?上面的代碼獲取columnId(例如pivot_2),但setPinnedBottomRowData([{pivot_2:100,...}])似乎沒有注意到這一點? – Andrew

0

我對固定行的pivot_類型做了什麼:我在我的列中添加了一個自定義固定行渲染器,我期望聚合函數能夠顯示(對於我來說它是sum和avg)。如果我更改了透視函數,我調用了固定行上的刷新來設置新值。

pinnedRowCellRenderer: function (render) 
      { 
       for (var obj_id in render.data) 
       { 
        if (obj_id == render.column.colId) 
        { 
         return '<div>' + render.data[obj_id] + '</div>'; 
        } 
       } 
       return '<div></div>'; 
      } 

而結果是這樣的: Result image

希望它能幫助!

相關問題

 相關問題