-
-
Notifications
You must be signed in to change notification settings - Fork 156
Description
As I was struggling to get get styling of the SmartTable to work, I finally found the reason in a wrong documentation of your website.
I am using a template to override the default display of cells:
<ng-template cTemplateId="tableData" ...
I want to apply different css-classes to different cells, so I used your example:
Column-Definition:
columns: (IColumn | string)[] = [
{
key: '...',
label: '...',
_classes: 'autofit',
_colClass: 'text-end'
}
]
(Note: _colClass is not documented, I found it when looking through coreui code.)
Cell-Definition:
<ng-template cTemplateId="tableData" let-columnName="columnName" let-item="item" let-tdContent="tdContent">
<td [ngClass]="smartTable.getTableDataCellClass(item, columnName)">
...
But the td never got the _colClass assigned.
After some try-and-error and digging through coreui code, I finally found the correct solution and strongly suggest, to correct your documentation:
- The column parameter for getTableDataCellClass() is wrong: It is not "columnName", but "column", which you can get with let-column="column" (which is not documented)
- The order of params for getTableDataCellClass() is wrong: Is is not item, column, but column, item
So the correct code to get _colClass passed to the cell is:
<ng-template cTemplateId="tableData" let-column="column" let-item="item" let-tdContent="tdContent">
<td [ngClass]="smartTable.getTableDataCellClass(column, item)">
...
Maybe this could be avoided, by getting a better type checking for getTableDataCellClass?
I really like the SmartTable and I think its a very powerful component. But the documentation is sadly not as powerful as it should be.