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

前端 未结 9 1217
长情又很酷
长情又很酷 2021-02-19 00:22

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

9条回答
  •  借酒劲吻你
    2021-02-19 01:04

    Assign a class to the cell as below:

    gridOptions = {
      ...
      columnDefs: [
        ...
            { headerName: "field1", field: "field1", cellClass: "grid-cell-centered"}
        ...
      ]
    }
    

    css file:

    .grid-cell-centered {
      text-align: center;
    }
    

提交回复
热议问题