I'm currently attempting to access a single cell on an ag-grid using Angular 6. The HTML structure is as follows:
<ag-grid-angular
style="width: 700px; height: 200px;"
class="ag-theme-balham"
[rowData]="rowData"
[columnDefs]="columnDefs"
rowSelection="single"
colDef.editable=true
(gridReady)="onGridReady($event)"
>
</ag-grid-angular>
The TypeScript class code is:
ngOnInit() {
}
onGridReady(params){
this.gridApi = params.api
this.columnApi = params.columnApi
}
updateRow(){
var rowNode = this.gridApi.getRowNode(0);
rowNode.setData(
{ make: 'changed', model: 'changed', price: 10 },
)
}
updateCell(){
var rowNode = this.gridApi.getRowNode(0);
this.gridApi.getRowNode(0)
rowNode.setDataValue("model","mobile")
}
addColumn(){
var rowNode = this.gridApi.getRowNode(0);
var x = parseInt(rowNode.data.price)
var rowNode = this.gridApi.getRowNode(1);
var y = parseInt(rowNode.data.price)
var rowNode = this.gridApi.getRowNode(2);
var z = parseInt(rowNode.data.price)
console.log("price", x ,y, z)
this.total = x+y+z
}
columnDefs = [
// use this for the whole column {headerName: 'Make', field: 'make',cellStyle: { 'border-bottom': '3px double'} },
{headerName: 'Make', field: 'make',cellStyle: {
// you can use either came case or dashes, the grid converts to whats needed
backgroundColor: '#aaffaa' // light green
}},
{headerName: 'Model', field: 'model'},
{headerName: 'Price', field: 'price', editable: true},
{headerName: '', field: '', editable: true}
];
rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000, cellClass: "col-1" },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxter', price: 72000 }
];
I have successfully targeted a column using cellstyle but I am now trying to add borders to each individual cell. Is there a way to target a specific cell similar to how I've done with:
var rowNode = this.gridApi.getRowNode(1);
and apply a style to the rowNode or is there another method to accomplish this?