I create a ag-grid and I have headerName which is date, time and location.
here's the code
list.component.ts
columnDefs: any = [{
headerName: 'Date',
field: 'date',
valueFormatter: (data: any) => {
let date = new Date(data.value);
const month = date.getMonth;
return data.value ? month : '';
},
rowGroup: true,
hide: true
},
{
headerName: 'Time',
field: 'date',
valueFormatter: (data: any) => {
return data.value ? (format(data.value, 'hh:mm:ss a')) : '';
},
},
{
headerName: 'Location',
field: 'sensor'
}
]
How to group it based on their date. Thanks in advance.
columnDefs: any = [{
headerName: 'Date',
field: 'date',
valueFormatter: (data: any) => {
let date = new Date(data.value);
const month = date.getMonth;
return data.value ? month : '';
},
rowGroup: true,
hide: true
},
{
headerName: 'Time',
field: 'date',
valueFormatter: (data: any) => {
return data.value ? (format(data.value, 'hh:mm:ss a')) : '';
},
},
{
headerName: 'Location',
field: 'sensor'
}
]
You can use this
at list.component.ts
onGridReady(params: GridReadyEvent) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.gridColumnApi.getColumn('date').setSort('asc');
}
It may help you for grouping with sorting by date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.