Angular table orderBy列

时间:2017-09-12 05:14:53

标签: angularjs angularjs-orderby

我尝试使用角度表顺序按日期列(降序)。但它不起作用(日期列数据类型是String,在某些情况下必须获取String数据类型)。请帮助我。

示例数据

Trans.Date | Receipt / Ref No | Trx Code | Description | Receipt Amt | Debit     | Credit | Running Balance 

2013-08-15 | 000000000001     | OST      |  OST        | 0.00        |  150.00   | 0.00   | 150.00       
2013-08-15 | 000000000001     | OTH      |  Amounts    | 0.00        |  8,000.00 | 0.00   | 8,150.00     
2013-09-15 | 000000000001     | RNT      |  Rental     | 0.00        |  3,041.00 | 0.00   | 11,191.00    
2013-10-15 | 000000000002     | RNT      |  Rental     | 0.00        |  3,041.00 | 0.00   | 14,232.00   

代码

<table id="tblTrans" class="display table-bordered" cellspacing="0" width="100%" style="font-size: small;">
<thead>
    <tr>
        <th>Date</th>
        <th>Receipt / Ref No</th>
        <th>Trx Code</th>
        <th>Description</th>
        <th>Pay Mode</th>
        <th>Receipt Amt</th>
        <th>Debit</th>
        <th>Credit</th>
        <th>Running Balance</th>
    </tr>
</thead>
<tbody>
    <tr ng-repeat="objtrn in transactions | orderBy:'TRNDATE' | startFrom:currentPageTrn*pageSize | limitTo:pageSize ">
        <td>{{objtrn.TRNDATE}}</td>
        <td>{{objtrn.TRNNO}}</td>                               
        <td>{{objtrn.TRNCODE}}</td>
        <td>{{objtrn.DESCR}}</td> 
        <td>{{objtrn.PAYMODE}}</td>  
        <td style="text-align:right">{{objtrn.TRNAMT | number:2}}</td>  
        <td style="text-align:right">{{objtrn.DEBIT | number:2}}</td>  
        <td style="text-align:right">{{objtrn.CREDIT | number:2}}</td>  
        <td style="text-align:right">{{objtrn.RUNBAL | number:2}}</td>  
    </tr>
</tbody>

2 个答案:

答案 0 :(得分:0)

使用反向参数(请参阅documentation

语法为:orderBy : expression : reverse : comparator

在您的情况下,请将过滤器更改为:

orderBy:'TRNDATE':true

答案 1 :(得分:0)

试试这个:orderBy:'-TRNDATE'。我以崇敬的方式为id这样做了。所以希望它会对你有所帮助。