作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 <p-table>
,我必须对其标题进行排序。我正在做如下:
HTML
<p-table [value]="documents">
<ng-template pTemplate="header">
<tr>
<th [pSortableColumn]="">
File Name
<p-sortIcon [field]=""></p-sortIcon>
</th>
<th [pSortableColumn]="">
File Type
<p-sortIcon [field]=""></p-sortIcon>
</th>
<th [pSortableColumn]="">
File Date
<p-sortIcon [field]=""></p-sortIcon>
</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-doc>
<tr>
<td>
{{doc.sName}}
</td>
<td>
{{doc.sType}}
</td>
<td>
{{doc.sDate}}
</td>
</tr>
</ng-template>
</p-table>
ngOnInit(){
//made a service call and got data for
this.documents=[{
"sName":"Book",
"sType":"PDF",
"sDate":"20"
},
{
"sName":"Book",
"sType":"PDF",
"sDate":"20"
},
{
"sName":"Cook Book",
"sType":"Text",
"sDate":"20"
},
{
"sName":"Book",
"sType":"PDF",
"sDate":"25-04"
},
{
"sName":"File",
"sType":"PDF",
"sDate":"02-01"
}]
}
[pSortableColumn]
和
[field]
,但我没有得到传递什么值来对特定字段进行排序。数据正确弹出,它只是我缺少的排序。请指导我如何实现列的排序。谢谢
<p-dataTable>
最佳答案
替换
<th [pSortableColumn]="">
File Name
<p-sortIcon [field]=""></p-sortIcon>
</th>
使用
<th [pSortableColumn]="'sName'">
File Name
<p-sortIcon [field]=""></p-sortIcon>
</th>
例如,为了按名称排序。
关于angular - PrimgNg : <p-table> column sorting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51082639/
我正在使用 ,我必须对其标题进行排序。我正在做如下: HTML File Nam
我是一名优秀的程序员,十分优秀!