Page 1 of 1

Dynamic bodyClass for DataTable Column

Posted: 07 Aug 2022, 20:24
by ricombnation
I need to set the background color of a DataTable Column (bodyClass) based on a property of the row data. Is there any way to achieve this?

As a workaround, I can set a fixed height in the body template of the column, but the I get into trouble with the responsiveness.

Re: Dynamic bodyClass for DataTable Column

Posted: 11 Aug 2022, 16:14
by tugce.kucukoglu
Could you please check this example https://codesandbox.io/s/mnvnsc?file=/s ... ue:283-339, especially 'Quantity' column.

Thanks,

Re: Dynamic bodyClass for DataTable Column

Posted: 11 Aug 2022, 16:25
by ricombnation
Thanks for the example and the reply. However, I would like to apply the class (dynamically) to the <td> element and not the content.

Re: Dynamic bodyClass for DataTable Column

Posted: 23 Aug 2022, 07:59
by riverman83
Thanks for the reply @tugce.kucukoglu.
I was exactly looking for the :rowClass feature to dynamically style rows, depending on the {data}.

Made my day