Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I center the text in the headers for an AG-grid control?

Tags:

How can I center the text in the headers for an AG-grid control? I have tried using cellstyle and cellclass in the column definition but that did not work. Thank you

like image 416
user7400346 Avatar asked Sep 29 '17 13:09

user7400346


People also ask

How do I wrap text in Ag grid header?

In version 28 of AG Grid we added support for wrapping header cell text. This is done with the Wrap Header Text and Auto Header Height properties. Adding wrapHeaderText: true will cause long headers to wrap, but if some are longer than the actual height of the header then they will be shown truncated.

How do I add a tooltip to Ag grid column header?

You need to use the tooltipValueGetter property and set this in defaultColDef to params. value . defaultColDef = { tooltipValueGetter: (params) => { return params. value; } };

How do you add a header row in Ag grid?

In your data rows: you have to enter in the first column the title you want for each row. Show activity on this post. Add this as your first colDef . It will render a index column that is unmovable.

What is grid header?

The grid header displays the view's header. The table below lists the main properties affecting element behavior and appearance. Characteristics. Members. Value.


2 Answers

I'm using react and I just added the following snippet to my Table component's .css

.ag-header-cell-label {    justify-content: center; } 

I'm overriding the .css class class from ag-grid which I found via devtools inspection, and discovered it's using flexbox for display.

See example (not react but same concept): https://embed.plnkr.co/O3NI4WgHxkFiJCyacn0r/

like image 90
Alex Wachira Avatar answered Sep 16 '22 13:09

Alex Wachira


You may use this property:

cellStyle: {textAlign: 'center'} 
like image 40
Maharramoff Avatar answered Sep 17 '22 13:09

Maharramoff