Upon reviewing the code snippet within data-table-component-demo1.ts from the Git project you have downloaded:
<data-table id="persons-grid"
[header] = "false"
[multiSelect] = "false"
[substituteRows]="false"
[indexColumn]="false"
[items]="items"
[itemCount]="itemCount"
(reload)="reloadItems($event)"
[pagination]="false"
(rowClick)="rowClick($event)"
[rowColors] = "callBackForChangineRowColors"
>
<data-table-column
[property]="'name'"
[header]="'Name'"
[sortable]="true"
[styleClass]="someExplicitClass"
You can assign 'someExplicitClass' to [styleClass] as seen above and define this class in the data-table-component-demo1.css file like so:
:host /deep/ .someExplicitClass{
background-color:red;
}
However, this style applies to the entire DataColumn rather than specific aspects.
To apply only the background color indirectly, utilize the rowEvent variable within the rowClick(rowEvent) function in 'data-table-component-demo1.ts'
When clicking on a row, set the selected property to true triggering the onRowSelectChanged function in table.component.ts
By setting [rowColors] to "callBackForChangineRowColors" and adjusting data-table-component-demo1.component.ts with the following changes:
rowClick(rowEvent) {
console.log('Clicked: ' + rowEvent.row.item.name);
rowEvent.row.selected = true;
}
callBackForChangineRowColors(a,b,c)
{
if(b.selected)
return 'blue';
}
This approach explicitly assigns blue color to the selected Row.
*Unfortunately, there is no readily available input parameter like [styleClass] to apply other styles specifically at a granular level, as it wasn't exposed as an @Input in column.component.ts. If you have any solutions or ideas, please share them.