coreui / coreui-angular

CoreUI Components Library for Angular https://coreui.io/angular/docs/
https://coreui.io/angular/
MIT License
248 stars 146 forks source link

Sample code for cell color in smart table #154

Closed 32x0lf closed 1 year ago

32x0lf commented 1 year ago

Hello,

In the document there is no sample code for cell color in smart table component. I was trying to give a cell color based on the data. like for example: valid or invalid, if it is valid I want to color the whole row with green or any color and red for invalid. Like what's in the document. I want to achieve the same as that. image

Thank you in advance.

xidedix commented 1 year ago

@32x0lf as a temp workaround you can pass cTableColor for each td in a tr in ng-template cTemplateId="tableData" sth like:

<c-smart-table ...>
  ...
  <ng-template cTemplateId="tableData" let-columnName="columnName" let-item="item" let-tdContent="tdContent">
    <td [cTableColor]="item.status==='Banned' ? 'danger' : 'success'">
      {{tdContent}}
    </td>
  </ng-template>
</c-smart-table>

See: https://coreui.io/angular/docs/components/smart-table#basic-usage

32x0lf commented 1 year ago

@xidedix

Thank you for the solution.