Ag-grid how to format rows/row groups?

Hi, I have tried most of the proposed solutions to format rows in Aggrid but had no success.

I am trying to format either the row groups based on some condition, or format as percent individual rows based on the value of column data_type == ‘ratio’;

I tried this example but without success

data = df

builder = GridOptionsBuilder.from_dataframe(data)

# makes columns resizable, sortable and filterable by default
builder.configure_default_column(
    resizable=True,
    filterable=False,
    sortable=True,
    editable=False,
)

builder.configure_column(
    field="report_type",
    hide=True,
    header_name="Report Type",
    width=150,  # set width as per your requirement
    rowGroup=True,  # enables row grouping for this column
)

builder.configure_column(
    field="data_type",
    header_name="Data Type",
    # hide=True,
    rowGroup=True,  # enables row grouping for this column
)

builder.configure_column(
    field="standardized_descricao_da_conta",
    header_name="Descrição",
    pinned="left",
    width=150,  # set width as per your requirement
)


builder.configure_grid_options(
    groupDefaultExpanded=-1,
    suppressColumnVirtualisation=True,
    groupDisplayType="groupRows",
    autoGroupColumnDef=dict(
        minWidth=150,
        pinned="left",
        cellRendererParams=dict(suppressCount=True),
    ),
)


gridOptions = builder.build()


AgGrid(
    data,
    gridOptions=gridOptions,
    height=1000,
    theme="alpine",
    columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
    allow_unsafe_jscode=True,
)

Hi @pmshadow33

There is a similar forum post here that provides a few solution.

Hope this helps!

Best regards,
Chanin

1 Like