Html 如何使用Angularjs中的自定义过滤器将特定记录带到表的最后一行?
我正在处理angularjs,我需要使用自定义过滤器将特定记录带到表的最后一行。但是,没有做到这一点 这是我正在使用的Html 如何使用Angularjs中的自定义过滤器将特定记录带到表的最后一行?,html,angularjs,Html,Angularjs,我正在处理angularjs,我需要使用自定义过滤器将特定记录带到表的最后一行。但是,没有做到这一点 这是我正在使用的Html和脚本 <table class="table table-bordered"> <thead ng-hide="content == 'true'"> <tr> <th th-sort by="order" reverse="reverse" order="'bucket'">Bucket</
Html
和脚本
<table class="table table-bordered">
<thead ng-hide="content == 'true'">
<tr>
<th th-sort by="order" reverse="reverse" order="'bucket'">Bucket</th>
<th th-sort by="order" reverse="reverse" order="'product'">Product</th>
<th th-sort by="order" reverse="reverse" order="'countOfAllocatedAccount'">Allocated # </th>
<th th-sort by="order" reverse="reverse" order="'countOfCollectedAccount'">Collected #</th>
<th th-sort by="order" reverse="reverse" order="'countOfPendingCollectionOfAccounts'">Pending #</th>
</tr>
</thead>
<thead ng-show="content == 'true'">
<tr>
<th th-sort by="order" reverse="reverse" order="'bucket'">Bucket</th>
<th th-sort by="order" reverse="reverse" order="'product'">Product</th>
<th th-sort by="order" reverse="reverse" order="'sumOfAllocatedAccount'">Total Allocated Amount</th>
<th th-sort by="order" reverse="reverse" order="'sumOfCollectedAccount'">Total Collected Amount</th>
<th th-sort by="order" reverse="reverse" order="'sumOfPendingAllocatedAndCollectedAmounts'">Total Pending Amount </th>
</tr>
</thead>
<tbody>
<tr ng-hide="content == 'true'" ng ng-repeat='p in view_data | orderByValue'>
<td><span>{{p.pseudoBucket}}</span></td>
<td><span>{{p.product}}</span></td>
<td><span>{{p.countOfAllocatedAccount}}</span></td>
<td><span>{{p.countOfCollectedAccount}}</span></td>
<td><span>{{p.countOfPendingCollectionOfAccounts}}</span></td>
</tr>
<tr ng-show="content == 'true'" ng-repeat='p in view_data'>
<td><span >{{p.pseudoBucket}}</span></td>
<td><span>{{p.product}}</span></td>
<td><span>{{p.sumOfAllocatedAccount}}</span></td>
<td><span>{{p.sumOfCollectedAccount}}</span></td>
<td><span>{{p.sumOfPendingAllocatedAndCollectedAmounts}}</span></td>
</tr>
</tbody>
</table>
让我分享一下我现在得到的输出图像
我想把>90“排到最后一行。有人能帮我吗?我认为您的问题是,对于某些数据元素,您没有伪桶值
var数据=[{“产品”:“SBHL”,“bucket”:“>90”,“伪bucket”:“>90”,“分配的计数”:3005,“收集的计数”:0,“收集的计数”:3005,“分配的计数”:60549185,“收集的计数”:0,“分配的计数和收集的计数”:60549185},“产品”:“SBHL+,“bucket”:“>90”,“伪bucket”:,“countOfAllocatedAccount”:321,“countOfCollectedAccount”:0,“CountOfPendingCollectionFaccounts”:321,“sumOfAllocatedAccount”:23987045,“sumOfCollectedAccount”:0,“SumofPendingAllocatedCollectedAccount”:23987045},{“产品”:“SBML”,“bucket”:“>90”,“伪bucket”:““countOfAllocatedAccount”:732,“CollectedAccount”:0,”CountofPendingCollectionFaccounts:732,“sumOfAllocatedAccount”:109971610,“sumOfCollectedAccount”:0,“sumOfPendingAllocatedAndCollectedAmounts”:109971610},{“产品”:“SBML+”,“桶”:“>90”,“伪桶”:“,“countOfAllocatedAccount”:31,“countOfCollectedAccount”:0,“CountofPendingCollectionFaccounts”:31,“sumOfAllocatedAccount”:18662882,“Sumof CollectedAccount:0,“Sumof PendingAllocated and CollectedAmounts:18662882},{“产品”:“SBML+”,“桶”:“1-30”,“伪桶”:“1-30”,“countOfAllocatedAccount”:42,“countOfCollectedAccount”:0,“CountofPendingCollectionFaccounts”:42,“Sumof AllocatedAccount”:1470250,“Sumof PendingAllocated and CollectedAccounts”:1470250},{”产品“:”SBML“,”bucket“:”1-30“,”伪bucket“,”AllocatedAccount:”942“,”CollectedAccount:”0“,”CountofPendingCollectionFaccounts:”942“,”sumOfAllocatedAccount:”11904428“,”产品“:”SBHL+”,”bucket“,”1-30“,”伪bucket“,”AllocatedAccount:”596“,”集合帐户计数:0,“集合帐户计数”:596,“集合帐户计数”:3961615,“集合帐户计数”:0,“集合帐户计数”:3961615},{“产品”:“SBHL”,“桶”:“1-30”,“伪桶”:“集合帐户计数”:4810,“集合帐户计数”:0,“集合帐户计数”:4810Sumof AllocatedAccount:14549696,“Sumof CollectedAccount:0,“Sumof PendingAllocatedAndCollectedAmounts:14549696},{“产品”:“SBHL”,“bucket”:“31-60”,“伪bucket”:“31-60”,“countOfAllocatedAccount”:1610,“countOfCollectedAccount”:0,“CountofPendingCollectedAccounts”:1610,“Sumof AllocatedAccount”:9369038,“Sumof CollectedAccount:0,”SumofPendingAllocatedCollectedAmounts:9369038},{“产品”:“SBHL+”,“桶”:“31-60”,“伪桶”:“AllocatedAccount”:182,“CollectedAccount”:0,“CountofPendingCollectionFaccounts”:182,“sumOfAllocatedAccount”:2353302,“SumofPendingAllocatedCollectedAmounts”:2353302},{“产品”:“SBML”,“桶”:“31-60”伪桶“:”,“分配数量”:275,“收集数量”:0,“分配数量”:275,“分配数量”:7096213,“收集数量”:0,“分配数量”和“收集数量”:7096213},{“产品”:“SBML+”,“桶“:“31-60”,“伪桶”:“分配数量”:16,“收集数量”:0,”CountofpendingCollectionFaccounts:16,“sumOfAllocatedAccount”:1147017,“sumOfCollectedAccount”:0,“sumOfPendingAllocatedAndCollectedAmounts”:1147017},{“产品”:“SBML+”,“桶”:“61-90”,“伪桶”:“61-90”,“countOfAllocatedAccount”:10,“countOfCollectedAccount”:0,“CountofPendingCollectionFaccounts”:10,“sumOfAllocatedAccount”:1191800,“Sumof CollectedAccount:0,“Sumof PendingAllocatedCollectedAccount:1191800},{“产品”:“SBML”,“桶”:“61-90”,“伪桶”:“countOfAllocatedAccount”:184,“countOfCollectedAccount”:0,“CountofPendingCollectionFaccounts”:184,“Sumof AllocatedAccount”:7378650,“Sumof CollectedAccount”:0,“Sumof PendingAllocatedCollectedAccount:7378650},{“产品”“:“SBHL+”,“bucket”:“61-90”,“pseudoBucket”:“countOfAllocatedAccount”:79,“countOfCollectedAccount”:0,“CountofPendingCollectionFaccounts”:79,“sumOfAllocatedAccount”:1618234,“sumOfCollectedAccount”:0,“SumofPendingAllocatedAccounts”:1618234},{“product”:“SBHL”,“bucket”:“61-90”,“pseudoBucket”:“countOfAllocatedAccount”:793,“已收集会计科目数”:0,“已收集会计科目数”:793,“已收集会计科目数”:6799247,“已收集会计科目数”:0,“已收集会计科目数”:6799247}]
//我认为您的问题在于,对于某些数据元素,您没有伪桶值
//因此,它将>90放入普通过滤数组中。
var fx=[],
f=[];
data.forEach(el=>{
//这里也添加了el.bucket检查
如果(el.pseudoBucket==>90“| | el.bucket===>90”){
fx.拼接(0,0,el);
}else if(el.pseudoBucket.indexOf(“>”)==-1){
f、 推(el);
}否则{
外汇推(el);
}
});
f=f.concat(fx);
//将以>90为最后一个的顺序打印
f、 forEach(el=>console.log(el.pseudoBucket));
Last column您指的是最后一个索引?@inoabrian我已经为澄清分享了输出图像。前四条记录的值为“>90”“我需要在最后一列中说明这一点。你是说最后一行吗?因此,表的顶部是1-30,底部是>90?@JokerDan yeap filteredX返回时的确切外观。我想查看一些示例数据,而不是制作自己的数据。@inoabrain我无法在html表中看到>90的值。
CollectApp.filter('orderByValue', function() {
//$scope.reverse = true;
alert("Rajini");
return function(items, field) {
var filtered = [],
filteredX = [];
angular.forEach(items, function(p) {
if (p.pseudoBucket == ">90") {
filteredX.splice(0, 0, p);
} else if (p.pseudoBucket.indexOf(">") == -1) {
filtered.push(p);
} else {
filteredX.push(p);
}
});
angular.forEach(filtered, function(p) {
filteredX.push(p);
});
return filteredX;
//console.log("hi");
};
});