I am using Angular 6 and ag grid version 18. I want to have an option from the context menu to increase and decrease the fontsize
I want a feature something like this. I tried rowstyle,cellstyle that did not work
I am using Angular 6 and ag grid version 18. I want to have an option from the context menu to increase and decrease the fontsize
I want a feature something like this. I tried rowstyle,cellstyle that did not work
Below is how the column definition looks like. Note I am using variable a
for incrementing and decrementing the font size -
var a = 10;
var columnDefs = [
{headerName: 'Athlete', field: 'athlete', width: 150,
cellStyle: function(params) {
return {fontSize: params.context.a + 'px', backgroundColor: 'green'};
}
},
..
];
Set the reference to your component as below, this will be used in context menu callbacks -
var gridOptions = {
context: this,
..
};
Below is the cell refresh and context menu -
function refreshCells() {
var params = {
force: true
};
gridOptions.api.refreshCells(params);
}
function getContextMenuItems(params) {
var result = [
{
// custom item
name: 'Increase Font',
action: function() {
params.context.a = params.context.a + 5;
params.context.refreshCells();
},
},
{
// custom item
name: 'Decrease Font',
action: function() {
params.context.a = params.context.a - 5;
params.context.refreshCells();
},
}
];
return result;
}
Please see Plunkr - Increase/decrease font ag-grid plunkr