多语言展示
当前在线:1016今日阅读:27今日分享:41

java框架教程

关于angular表格table点击表头按字段排序的方法
工具/原料

angular.min.1.2.js

方法/步骤
1

js获取数据investService.getNewStacksList().success(function(response){ if(response.op.code == "Y"){ var tempInfomationList = []; angular.forEach(response.list,function(newstack){ tempInfomationList.push(newstack); }); $scope.col = "sub_bgn_dt_on";      //默认按sub_bgn_dt_on字段排序 $scope.newstackslist = tempInfomationList; } $scope.$apply(); });

2

2、定义一个filter,以便前端的html使用angular.module("gp").filter("newstacksFilter",function(){return function(newstackslist,s_val){var tempInfomationList = [];angular.forEach(newstackslist,function(newstackInfo){if(s_val!=null && s_val!=""){if((newstackInfo.trd_code).indexOf(s_val)>=0   || (newstackInfo.secu_sht).indexOf(s_val)>=0){tempInfomationList.push(newstackInfo);}}else{tempInfomationList = newstackslist;}});return tempInfomationList;}})

3

2、html部分代码 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
股票代码股票名称申购
代码
发行
总数
(万股)
网上
发行
(万股)
申购
上限
(万股)
申购资
金上限
(万元)
发行
价格
最新价申购
日期
                   

4

最后效果图:注:点击表头文字链可进行排序。如:点击“发行价格”按发行价格排序

注意事项

主要是注意filter这一块

推荐信息