Niels Bosma
Niels Bosma

Reputation: 11498

ag-grid: how to set --ag-grid-size using javascript

I'm using the ag-grid with vanilla js.

I want to set the --ag-grid-size: using javascript so the user can toggle between

I've tried:

document.body.style.setProperty('--ag-grid-size', '3px');

But it won't update.

Made a plunker here:

https://plnkr.co/edit/90G4nOJbFPar6P8v?open=main.js

Upvotes: 0

Views: 92

Answers (1)

mashi
mashi

Reputation: 627

It seems, grid calculates heights during initialization, and then it is not enough to change CSS variable. You also need to call some API methods:

api.setGetRowHeight(() => 8 * size);
api.setHeaderHeight(7*size)
api.resetRowHeights()

https://plnkr.co/edit/D5L8dwqT8EzPatJi?open=main.js

Upvotes: 1

Related Questions