Skip to content
Discussion options

You must be logged in to vote

Hi @tz301,

According to https://stackoverflow.com/questions/46490177/how-can-i-center-the-text-in-the-headers-for-an-ag-grid-control we can't control the header alignment via AG Grid options, but with custom CSS:

ui.add_style('''
    .ag-header-cell-label {
        justify-content: center;
    }
''')

ui.aggrid({
    'columnDefs': [{'field': 'name', 'headerName': 'Name', 'cellStyle':  {'textAlign': 'center'}}],
    'rowData': [{'name': 'Alice'}, {'name': 'Bob'}],
})

Or if you want to target a specific AG Grid element:

ui.add_style('''
    .my-aggrid .ag-header-cell-label {
        justify-content: center;
    }
''')

ui.aggrid({
    'columnDefs': [{'field': 'name', 'headerName': 'Name', '…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tz301
Comment options

Answer selected by tz301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants