Hi everyone i'm working on angularjs to display list of records in table . The difficulty i'm facing is to display the table in ascending order, i have used the alphabet record (X) which i need to display has the first record in the table.
大家好,我正在使用angularjs在表中显示记录列表。我面临的困难是按升序显示表,我使用了我需要显示的字母表记录(X),它在表中有第一个记录。
Let me give you the html page.
让我给你一个html页面。
<table class="table table-bordered">
<thead>
<tr>
<th ng-click="sort('bucket')" th-sort by="order">Bucket<span class="sortorder descending" ng-hide="(sortKey=='bucket' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='bucket' && reverse==false)"></span>
</th>
<th ng-click="sort('productCode')" th-sort by="order">Product Code<span class="sortorder descending" ng-hide="(sortKey=='productCode' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='productCode' && reverse==false)"></span>
</th>
<th ng-click="sort('countOfAllocatedAccount')" th-sort by="order">Allocated
<span class="sortorder descending" ng-hide="(sortKey=='countOfAllocatedAccount' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='countOfAllocatedAccount' && reverse==false)"></span>
</th>
<th ng-click="sort('countOfCollectedAccount')" th-sort by="order">Collected
<span class="sortorder descending" ng-hide="(sortKey=='countOfCollectedAccount' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='countOfCollectedAccount' && reverse==false)"></span></th>
<th ng-click="sort('sumOfArrearsOfAllocatedAmount')" th-sort by="order">Total Allocated Amount
<span class="sortorder descending" ng-hide="(sortKey=='sumOfArrearsOfAllocatedAmount' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='sumOfArrearsOfAllocatedAmount' && reverse==false)"></span>
</th>
<th ng-click="sort('sumOfCollectedAmount')" th-sort by="order">Total Collected Amount
<span class="sortorder descending" ng-hide="(sortKey=='sumOfCollectedAmount' && reverse==true)"></span>
<span class="sortorder" ng-hide="(sortKey=='sumOfCollectedAmount' && reverse==false)"></span></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in view_data">
<td><span ng-hide="view_data[$index-1].bucket == item.bucket">{{item.bucket}}</span></td>
<td>{{item.productCode}}</td>
<td>{{item.countOfAllocatedAccount}}</td>
<td>{{item.countOfCollectedAccount}}</td>
<td><span>{{item.sumOfArrearsOfAllocatedAmount | currency:"₹"}}</span></td>
<td>{{item.sumOfCollectedAmount | currency:"₹"}}</td>
</tr>
</tbody>
</table>
And let me show you the output :
我给你们看一下输出:
As shown in the image i need to set the bucket value X as first data in the record and rest in the ascending order. I'm stuck, Please anyone help me with this.
如图所示,我需要将bucket值X设置为记录中的第一个数据,其余数据按升序排列。我被困住了,请大家帮帮我。
1 个解决方案
#1
1
Try this:
试试这个:
<tr ng-repeat="item in view_data | orderBy: +item.bucket">
That should sort by that first field.
这应该按第一个字段排序。
#1
1
Try this:
试试这个:
<tr ng-repeat="item in view_data | orderBy: +item.bucket">
That should sort by that first field.
这应该按第一个字段排序。