简体   繁体   English

使用ag-grid的Agroup数据

[英]Agroup data using ag-grid

I am currently using ag-grid in my project. 我目前在我的项目中使用ag-grid。 Am trying to agroup the data using the agrouping feature. 我正在尝试使用分组功能对数据进行分组。

In my col def I have this: 在我的col def中,我有以下内容:

{headerName: "Parent", field: "ParentID",width: 120,rowGroup:true},
{headerName: "Name", field: "Name"},
{headerName: "Level", field: "Level"},
{headerName: "Active", field: "Active"},
{headerName: "Actions",
     field: "Actions",
     cellRenderer: function (params) {  
         /*Generate a link and return it*/
         return EditLink;
     }
    }

Then, the ag-grid options: 然后,ag-grid选项:

var gridOptions = {
    columnDefs: columnDefs,
    rowData: rowData,
    onGridReady: function () {
        gridOptions.api.sizeColumnsToFit();
    },
    animateRows: true,
    enableRangeSelection: true,
    enableSorting: true,
    enableFilter: true,
    enableColResize: true,
    domLayout:'autoHeight',
    rowHeight: 48,
    enableStatusBar: true,
    rowSelection: 'single',
    groupMultiAutoColumn:true,
    groupRemoveSingleChildren:true,
    icons: {
        checkboxChecked: '<img src="data:image/png;base64,SOMECODEHERE"/>'
    }
};

However, I am not getting the expected behaviour, I have the table rendered with the data and the column to agroup the data, but it's not agrouped, it's like ordered but I don't see the button to dropdown the children 但是,我没有得到预期的行为,我已经用数据呈现了表格,并且使用了将数据分组的列,但是没有将其分组,就像有序,但是我看不到下拉子项的按钮

Are you sure the ParentID is shared amongst several rows? 您确定在几行之间共享ParentID吗? The groupRemoveSingleChildren option will show no groups if no ids are shared. 如果没有共享ID,groupRemoveSingleChildren选项将不显示任何组。

You can also try using rowGroupIndex as opposed to rowGroup 您也可以尝试使用rowGroupIndex而不是rowGroup

ie

this.columnDefs = [
    {headerName: "Clan", field: "clan", editable: true, rowGroupIndex: 0 },

The rowGroupIndex allows sub groups to be defined so you can nest groups (if you need to). rowGroupIndex允许定义子组,以便您可以嵌套组(如果需要)。

I would also recommend removing the groupRemoveSingleChildren just to see if you get the checkbox or whether the data is at fault.. 我还建议删除groupRemoveSingleChildren只是为了查看是否获得复选框或数据是否有错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM