I'm facing an issue with displaying data in the pinned row within ag-Grid Vue 2. I am utilizing pinnedBottomRowData
to supply data for the pinned row, but despite the pinned row being visible, it remains empty. The problem arises from using dot notation in the field property of my JSON file data, like this:
field: "supplier.number"
. Unfortunately, this.gridApi.setPinnedBottomRowData
does not support dot notation, leading me to add colId: "supplierNumber"
. However, even with this change, the issue persists. When I remove the dot notation and replace it with field: "supplierNumber"
, it works fine. Sadly, modifying the JSON directly is not an option as the data comes from an external source.
The last resort would be creating a new object with the data from the JSON, though I prefer to avoid this workaround if possible. Can someone assist me with resolving this dilemma?
Below is my Code: Ag Grid
<ag-grid-vue
style="flex: auto; flex-direction: row; height: 650px"
:class="cssClass"
:columnDefs="columnDefs"
:rowData="supplierList"
:gridOptions="columnOptions"
:alwaysShowHorizontalScroll="true"
@grid-ready="onGridReady"
></ag-grid-vue>
Column Definitions:
columnDefs: [
{
headerName: "Information",
children: [
{
headerName: "Description",
colId: 'supplierDesc',
field: "supplier.desc",
},
{
headerName: "number",
colId: "supplierNumber",
field: "supplier.number"
},
],
},
{
headerName: "Header2",
children: [
{
headerName: "Supplier Budget",
colId:"supplierBudget",
field: "year2024.budget",
cellRenderer: (params) => this.currencyFormatter(params.value, "€"),
},
],}, ],
Function onGridReady
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.createData('Total:', this.supplierList);
},
This is the createData Function
createData(prefix,list) {
let calcTotalCols = ['supplierDesc', 'supplierNumber','supplierBudget'];
let total = [{}];
// initialize all total columns to zero
calcTotalCols.forEach(params => { total[0][params] = 0 });
// calculate all total columns
calcTotalCols.forEach(params => {
list.forEach(line => {
total[0][params] += line[params];
});
});
let result = [];
result.push({
supplierDesc: prefix + total[0]['supplierDesc'],
supplierNumber: prefix + total[0]['supplierNumber'],
supplierBudget: prefix + total[0]['supplierBudget'],
});
this.gridApi.setPinnedBottomRowData(result);
},