Pau*_*ems 14 angular2-template primeng angular
我们正在使用PrimeNG 1.0.0-beta.16的p-dataTable
我想在值为true时向行添加样式.我想出了如何用单元格做这个,但我需要整行改变它的背景.
<p-dataTable [hidden]="loading" [value]="timePeriods" scrollable="true" scrollHeight="400px" rowStyleClass="missingPeriod">
<p-column field="StartDate" header="Begindatum" sortable="false">
<template let-col let-timePeriod="rowData" pTemplate type="body">
<span [class.missingPeriod]="!timePeriod.IsNext">{{timePeriod.StartDate | date: 'dd-MM yyyy'}}</span>
</template>
</p-column>
<p-column field="EndDate" header="Einddatum" sortable="false">
<template let-col let-timePeriod="rowData" pTemplate type="body">
<span>{{timePeriod.EndDate | date: 'dd-MM yyyy'}}</span>
</template>
</p-column>
</p-dataTable>
Run Code Online (Sandbox Code Playgroud)
<span [class.missingPeriod]="!timePeriod.IsNext">
工作但rowStyleClass="missingPeriod"
不是.
请指教.
更新语法:
已更新至v1.0.1
<p-dataTable [hidden]="loading" [rowStyleClass]="customRowClass" [value]="timePeriods" scrollable="true" scrollHeight="400px">
<p-column field="StartDate" header="Begindatum" sortable="false">
<template let-col let-timePeriod="rowData" pTemplate type="body">
<span [class.missingPeriod]="!timePeriod.IsNext">{{timePeriod.StartDate | date: 'dd-MM yyyy'}}</span>
</template>
</p-column>
<p-column field="EndDate" header="Einddatum" sortable="false">
<template let-col let-timePeriod="rowData" pTemplate type="body">
<span>{{timePeriod.EndDate | date: 'dd-MM yyyy'}}</span>
</template>
</p-column>
</p-dataTable>
Run Code Online (Sandbox Code Playgroud)
打字稿:
public customRowClass(rowData, rowIndex): string {
console.log("In customRowClass");
console.log(rowData);
console.log(rowIndex);
return "";
}
Run Code Online (Sandbox Code Playgroud)
customRowClass
记录内部没有任何内容.在我看来,这个方法没有被调用.
Jon*_*ott 22
rowStyleClass
有点不同于你的想法; 它需要一个函数作为它的输入,它返回一个字符串(CSS类名).它列在PrimeNG DataTable文档中.
在我的HTML中,我得到了:
<p-dataTable [rowStyleClass]="lookupRowStyleClass" ...>
Run Code Online (Sandbox Code Playgroud)
在组件中:
lookupRowStyleClass(rowData: User) {
return rowData.accountDisabled ? 'disabled-account-row' : '';
}
Run Code Online (Sandbox Code Playgroud)
在全局CSS文件中:
/* TODO: this should really be in the component's CSS file, but it doesn't seem to apply to the PrimeNG data table properly there */
.disabled-account-row {
/* TODO: first try this without '!important', but you might need it */
color: silver !important;
}
Run Code Online (Sandbox Code Playgroud)
如果这没有帮助,则需要升级到更新版本.PrimeNG 1.0.0 RC5截至2016年11月.
归档时间: |
|
查看次数: |
22206 次 |
最近记录: |