7
<ngx-datatable
    id="ngxdatatable"
    class='material striped'
    [rows]="rows"
    [columns] ="columns"
>
</ngx-datatable>

我尝试绑定列,这些列在运行时使用类对象中的列属性获取。我想使用 css 使用单元格类来设置特定列的样式。如何做到这一点。请帮忙

4

1 回答 1

8

I would recommend looking at some of the source code for styling header and column cells as well as how to create column templates, such as:

https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/css.component.ts and https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/row-detail.component.ts

You can style the column headers by adding the [headerClass]="insertYourCssClassName" inside the column template tag like this:

<ngx-datatable-column
    name="ID"
    prop="id"
    [headerClass]="insertYourCssClassNameHere"
>

Same thing goes for styling the body cells, only with [cellClass] instead of [headerClass].

于 2017-06-26T17:45:58.403 回答