I have been using Primeng for a while.
I have used Primeng Datatable (p-dataTable) in my component. The component what I am trying to do is inbox. I read messages from DB to a model named 'Message' in Angular 2. There is a field in model named Read. Its used as a flag. Its Boolean. My requirement is if Read is false, entire row elements should be in one colour, say color1. If Read is true, entire row elements should be another color, say color2.
I know how to do the same using ngClass.
Can someone please suggest me how I can do the same using p-dataTable. I tried many ways I can by referring many sites & didn't find any. What I want is a functionality similar to ngClass in p-dataTable
Here is my code
In HTML
<p-dataTable [rowStyleClass]="readFlag" [value]="message" >
<p-column [style]="{'width':'38px'}" selectionMode="multiple"></p-column>
<p-column field="SenderUserId" header="From" [sortable]="true"></p-column>
<p-column class="icon-mandatory" field="Subject" header="Message"></p-column>
<p-column field="MessageDate" header="Time" [sortable]="true">
<template let-col let-message="rowData" pTemplate type="body">
<span>{{message.MessageDate | date: 'medium'}}</span>
</template>
</p-column>
</p-dataTable>
In Component
readFlag(rowData: Message) { return rowData.Read ? 'inbox-Read' : 'inbox-Unread' ; }
Message Model
export class Message
{
public Subject: string;
public Body: string;
public MessageDate: any;
public Read: boolean;
}