p-dataTable primeng angular2中的自定义排序问题

时间:2017-11-11 14:09:48

标签: angular primeng

我在ngOnInit()中对p-dataTable应用了自定义排序,但问题是它按照下面第一位的排序是我的代码

Html代码:

<p-dataTable [value]="filteredInv" scrollable="true" scrollHeight="calc(100vh - 300px)" [rows]="list" [paginator]="true" 
            responsive="true" sortField="itemno"  [resizableColumns]="false"  class="custom-pagi" [immutable]=false
            [hidden]="inCall" [(first)]="pageNo" (onPage)="changePage($event)" (onPageChange)="paginate($event)" [rowTrackBy]="rowTrackBy">
                <p-column title="itemno" field="itemno" header="itemno" [style]="{'width':'120px'}" styleClass="itemno-header border-column text-center"></p-column>
<p-column title="name" field="name" header="Item Name" styleClass="no-border-column-removed text-left"></p-column>
                <p-column title="max" field="max" header="Quantity" styleClass="no-border-column-removed text-left"></p-column>

    <p-dataTable>

Js代码:

  ngOnInit(){
    //Calling API to get data
     this.populateItems(data)
    }
populateItems(data) {        
    this.colHeaders = this.cols.slice();
    this.filteredInv = data.entities.slice();
    this.filteredInv.sort(function(a,b){return parseFloat(a.itemno) - 
    parseFloat(b.itemno)});   
}

enter image description here

任何帮助

0 个答案:

没有答案