2017-08-25 345 views
0

我試圖展示一些使用ag-grid進行分組的數據。數據正在正確顯示,但它沒有像應該那樣分組數據。我使用的是angularJS 1.5.8和ag-grid 12.0.2。這裏是我想要做一個非常簡化的版本:ag-grid分組不添加展開/摺疊控件

function _setGridOptions() { 
    var data = [ 
     {packageID: "one", documentID: "one-one", cost: 1}, 
     {packageID: "one", documentID: "one-two", cost: 2}, 
     {packageID: "one", documentID: "one-three", cost: 3}, 
     {packageID: "two", documentID: "two-one", cost: 4}, 
     {packageID: "two", documentID: "two-two", cost: 5}, 
     {packageID: "two", documentID: "two-three", cost: 6} 
    ]; 
    var cols = [ 
     { 
      headerName: "Package ID", 
      width: 100, 
      field: "packageID", 
      rowGroup: true 
     }, 
     { 
      headerName: "Document ID", 
      width: 100, 
      field: "documentID" 
     }, 
     { 
      headerName: "Cost", 
      width: 100, 
      field: "cost" 
     } 
    ]; 
    $ctrl.agGridOptions = { 
     columnDefs: cols, 
     animateRows: true, 
     enableRangeSelection: true, 
     rowData: data, 
     enableSorting: true, 
     debug: true, 
     enableColResize: true, 
     onGridReady: function() { 
      $ctrl.agGridOptions.api.sizeColumnsToFit(); 
     } 
    }; 
    $ctrl.transactionsLoaded = true; 
} 

,這裏是表的樣子:

enter image description here

正如你可以看到有沒有「集團」列,並且組行沒有展開/摺疊控制。

任何想法我做錯了什麼?

+0

你可以請分享HTML,如果可能的話,JSFiddle的問題。 –

+0

我想你需要添加groupUseEntireRow = true; groupRowRenderer:function(params){return params.node.key;在$ ctrl.agGridOptions中。 – 2017-08-25 17:42:58

+0

有關更多詳細信息,您可以訪問https://www.ag-grid.com/javascript-grid-grouping-headers/# if if not usfull than create snippest/fiddle – 2017-08-25 17:43:34

回答

0

我剛剛意識到問題所在。 「Grouping Rows」功能是企業功能,我正在使用免費版本。