0

I'm tryin to get all id's names from Row Group after clicking on 'Pivot mode' and it gives me just the name of 'Group'.

enter image description here

enter image description here

There is any way to get the name of 'Item'?

1 Answer 1

0

You can access event parameter whenever pivotMode is changed through columnPivotModeChanged. And you can also able to get RowGroupColumns by calling getRowGroupColumns() through columnApi in event parameter.

  1. columnPivotModeChanged()
event: ColumnPivotModeChangedEvent 

onColumnPivotModeChanged = (
    event: ColumnPivotModeChangedEvent<TData>
) => void;

interface ColumnPivotModeChangedEvent<TData = any> {
  // The grid api. 
  api: GridApi<TData>;
  // The column api. 
  columnApi: ColumnApi;
  // Application context as set on `gridOptions.context`. 
  context: any;
  // Event identifier 
  type: string;
}
  1. getRowGroupColumns()
function getRowGroupColumns(): Column[];

Example

main.js

const VueExample = {
  template: `
        <div style="height: 100%">
            <div class="example-wrapper">
                <ag-grid-vue
                style="width: 100%; height: 100%;"
                class="ag-theme-alpine"
                :columnDefs="columnDefs"
                @grid-ready="onGridReady"
                @columnPivotModeChanged="columnPivotModeChanged"
                :defaultColDef="defaultColDef"
                :autoGroupColumnDef="autoGroupColumnDef"
                :sideBar="sideBar"
                :rowData="rowData"></ag-grid-vue>
            </div>
        </div>
    `,
  methods: {
    onGridReady(params) {
      this.gridApi = params.api;
      this.gridColumnApi = params.columnApi;

      const updateData = (data) => params.api.setRowData(data);

      fetch('https://www.ag-grid.com/example-assets/olympic-winners.json')
        .then((resp) => resp.json())
        .then((data) => updateData(data));
    },
    columnPivotModeChanged(params: ColumnPivotModeChangedEvent){
      const rowGroupList = params.columnApi.getRowGroupColumns()

      console.log(rowGroupList.map(rowGroup => rowGroup.getColId()))
    }
  },

Reference

Grid-event: columnPivotModeChanged

Column-api: getRowGroupColumns

I hope this helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.