[Fixed] How to change the styles Dynamically in aggrid with an external button click?


cellClassRules: {‘makeRed’:’!this.flag’}

i want this flag variable based on a button click and then it should make changes in the grid

In Angular 8


On click of the button, you could set a variable in your component class to true. Something like :

<button (click) = "onButtonClick()"> My button </button>


public buttonClicked = false;

   this.buttonClicked = true;

Then in your column defs, you can do something like :

cellClassRules: {'makeRed':this.buttonClicked}

where makeRed is a CSS class that defines your custom properties.

Note: If you wish to do this for a button toggled behavior, then you’d need to do something like :

   this.buttonClicked = this.buttonClicked ? !this.buttonClicked : this.buttonClicked

cellClassRules: {
'makeGreen': !this.buttonClicked,

Leave a Reply

(*) Required, Your email will not be published