Recently, I came across a PrimeVue DataTable with a specific structure:
<DataTable value="info">
<Column header="Name" field="name" />
<Column header="Desc." field="desc" />
<Column header="Date" field="date" />
</DataTable>
The DataTable's value is filled with data from the "info" array, retrieved from an API. I've been trying to change the color of certain rows in the DataTable based on the "desc" property within the "info" array. Here's what I have attempted:
Using rowStyle
<DataTable value="info" :rowStyle="desc === 'Disconnected' ? 'color:red' : null">
<Column header="Name" field="name" />
<Column header="Desc." field="desc" />
<Column header="Date" field="date" />
</DataTable>
I've experimented with various versions of rowStyle, but my main challenge lies in accessing variables within the DataTable when applying styles. Would using a ColumnGroup and assigning a <Row>
value, then customizing it with the corresponding color change be a better approach?
Any assistance would be appreciated. Thank you!