3

I need to slightly modify a ag-grid row after it has been rendered. In ag-grid, the actual HTML elements are not necessarily persistent, so manually-set styles may fall off.

For one thing, I have to modify the selection checkbox to set its tabindex to -1. This can technically be done in the cellRenderer callback, although it looks quite hacky. (The checkbox can be found at params.eGridCell.children[0].children[0].wrappedElement.)

But I also have to add a CSS class to some rows to highlight them based on external criteria. I haven't found a way to do this at all.

The best solution would seem to be using some sort of after-rendering callback, but to my knowledge no such thing exists.

I found a couple of related questions, but they were both resolved via cellStyle, which would not suffice here:

un.spike
  • 4,857
  • 2
  • 18
  • 38
Thom Smith
  • 13,916
  • 6
  • 45
  • 91
  • Did you look here ? https://www.ag-grid.com/angular-grid-cell-styling/index.php you can use cellClassRules to adapt your class style to your needs. Use the eGridCell parameter has nothing off hacky, it was added in purpose you need it so i don't see any problem of doing it. – Walfrat Mar 09 '16 at 08:21
  • `cellClassRules`, understandably, puts classes on cells. – Thom Smith Mar 09 '16 at 14:11

1 Answers1

4

You have not 1 but 3 options:

getRowClass(params):

Callback version of property 'rowClass'. Function should return a string or an array of strings.

getRowStyle(params):

Callback version of property 'rowStyle'. Function should return an object of CSS values.

processRowPostCreate(params):

Allows you to process rows after they are created. So do final adding of custom attributes etc.

In this last one you have the row in params.eRow.

All taken from https://www.ag-grid.com/javascript-grid-callbacks/index.php

tfrascaroli
  • 1,178
  • 1
  • 14
  • 26
  • `processRowPostCreate` is what I really need -- however, this is new functionality that was introduced just yesterday! In lieu of that, `getRowClass` will do the trick. – Thom Smith Mar 10 '16 at 14:46
  • Yeah, Niall has been bussy this last week. But hey, `getRowClass` get's A LOT done with just a few css classes and a few conditionals. Glad to help :) – tfrascaroli Mar 11 '16 at 08:29