I am using the framework ag-grid () I have changed the row-height to 50px.
<div
className="ag-theme-balham"
style={{
height: '90vh',
width: '100%',
'font-size': '18px',
'row-height': '50px'
}}
>
<AgGridReact
rowHeight={50}
columnDefs={columnsTaenze}
rowSelection={'multiple'}
onFirstDataRendered={this.autoSizeAll}
rowDragManaged={true}
enableColResize={true}
animateRows={true}
rowData={this.props.tabledata}
enableFilter={true}
onRowDragEnd={this.onRowDragEnd}>
</AgGridReact>
</div>
Sadly, I can not manage to center the cell vertically.
I have tried to change many classes, including ag-cell
.
My css I tried:
.ag-cell{
line-height: 50px;
height: 100%;
vertical-align: middle;
}
But the cell isn`t centered:
Then in your ag-grid column definition use your custom css style in the cellClass property. Show activity on this post. cellStyle: { 'height': '100%', 'display': 'flex ', 'justify-content': 'center', 'align-items': 'center ', }, it's work for me.
Just add type: 'rightAligned' property.
To change the row height for the whole grid, set the property rowHeight to a positive number. For example, to set the height to 50px, do the following: const gridOptions = { rowHeight: 50, // other grid options ... } Changing the property will set a new row height for all rows, including pinned rows top and bottom.
To configure the column to have a checkbox, set colDef. headerCheckboxSelection=true . headerCheckboxSelection can also be a function, if you want the checkbox to appear sometimes (e.g. if the column is ordered first in the grid).
You can use below CSS. No need to use hard-coded values in CSS for height.
.ag-row .ag-cell {
display: flex;
justify-content: center; /* align horizontal */
align-items: center;
}
Have a look at this plunk: ag-grid: text-align vertically center
To build on @Paritosh's answer...
You don't have to overwrite the ag-grid styles themselves. You can do something like this in your own stylesheet:
.cell-vertical-align-text-left {
display: flex!important;
align-items: center;
}
.cell-vertical-align-text-right {
display: flex!important;
flex-direction: row-reverse;
text-align: right!important;
align-items: center;
}
Then in your ag-grid column definition use your custom css style in the cellClass
property.
var columnDefs = [
{
headerName: "Alerts",
colId: 'invoice_issues',
editable: false,
cellClass: "cell-border cell-vertical-align-text-right",
valueGetter: showInvoiceIssues,
autoHeight: true,
}
]
You can set cell style to following
cellStyle: {
'height': '100%',
'display': 'flex ',
'justify-content': 'center',
'align-items': 'center ',
},
it's work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With