I am having a hard time setting up an ag-grid table in an Angular 6.0 application where the row data model is a an array of simple types (dates, numbers, strings, etc.)
The only way I can do so is to wrap the all the data into an object list (each object containing a single property) and pass it as the row data. It also means that I have to manually and systematically have to unwrap the data whenever I need to access it.
To put it differently, is there a way to define a columnDef without a field in ag-grid table and having it consider implicitly that the field data is the entire row data?
var gridOptions = {
columnDefs: [
{headerName: 'Athlete'}
],
rowData: ['John', 'Oliver']
}
I think field is required but colId is not required (it will default to the field). Field is what maps a column to the data set. Here are more details about column definitions.
It may be easier to edit your data before initializing the grid. Something like this may work:
var data = ['John', 'Oliver'].map(name => {return {name} });
var gridOptions = {
columnDefs: [
{field:'name', headerName: 'Athlete'}
],
rowData: data
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With