table sorting–angularjs
1: <script type="text/javascript" ng:autobind
2: src="http://code.angularjs.org/0.10.5/angular-0.10.5.js"></script>
3:
4: <table ng:controller="SortableTableCtrl">
5: <thead>
6: <tr>
7: <th ng:repeat="(i,th) in head" ng:class="selectedCls(i)" ng:click="changeSorting(i)">{{th}}</th>
8: </tr>
9: </thead>
10: <tbody>
11: <tr ng:repeat="row in body.$orderBy(sort.column, sort.descending)">
12: <td>{{row.a}}</td>
13: <td>{{row.b}}</td>
14: <td>{{row.c}}</td>
15: </tr>
16: </tbody>
17: </table>
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
javaScript
1: function SortableTableCtrl() {
2: var scope = this;
3:
4: // data
5: scope.head = {
6: a: "Name",
7: b: "Surname",
8: c: "City"
9: };
10: scope.body = [{
11: a: "Hans",
12: b: "Mueller",
13: c: "Leipzig"
14: }, {
15: a: "Dieter",
16: b: "Zumpe",
17: c: "Berlin"
18: }, {
19: a: "Bernd",
20: b: "Danau",
21: c: "Muenchen"
22: }];
23:
24: scope.sort = {
25: column: 'b',
26: descending: false
27: };
28:
29: scope.selectedCls = function(column) {
30: return column == scope.sort.column && 'sort-' + scope.sort.descending;
31: };
32:
33: scope.changeSorting = function(column) {
34: var sort = scope.sort;
35: if (sort.column == column) {
36: sort.descending = !sort.descending;
37: } else {
38: sort.column = column;
39: sort.descending = false;
40: }
41: };
42: }CSS1: td { padding: 0.2em 1em; }2: th { text-align: center; }3: thead {4: border-bottom: 2px solid black;5: cursor: pointer;6: }7:8: /* http://www.greywyvern.com/code/php/binary2base64 */9:10: .sort-true {11: background:no-repeat right center url(data:image/gif;base64,R0lGODlhCgAKALMAAHFxcYKCgp2dnaampq+vr83NzeHh4f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAAAgAIf/8SUNDUkdCRzEwMTIAAAUwYXBwbAIgAABtbnRyUkdCIFhZWiAH2QACABkACwAaAAthY3NwQVBQTAAAAABhcHBsAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWFwcGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkc2NtAAABCAAAAvJkZXNjAAAD/AAAAG9nWFlaAAAEbAAAABR3dHB0AAAEgAAAABRyWFlaAAAElAAAABRiWFlaAAAEqAAAABRyVFJDAAAEvAAAAA5jcHJ0AAAEzAAAADhjaGFkAAAFBAAAACxn/1RSQwAABLwAAAAOYlRSQwAABLwAAAAObWx1YwAAAAAAAAARAAAADGVuVVMAAAAmAAACfmVzRVMAAAAmAAABgmRhREsAAAAuAAAB6mRlREUAAAAsAAABqGZpRkkAAAAoAAAA3GZyRlUAAAAoAAABKml0SVQAAAAoAAACVm5sTkwAAAAoAAACGG5iTk8AAAAmAAABBHB0QlIAAAAmAAABgnN2U0UAAAAmAAABBGphSlAAAAAaAAABUmtvS1IAAAAWAAACQHpoVFcAAAAWAAABbHpoQ04AAAAWAAAB1HJ1UlUAAAAiAAACpHBsUEwAAAAsAAACxgBZAGwAZQBpAG4AZf8AbgAgAFIARwBCAC0AcAByAG8AZgBpAGkAbABpAEcAZQBuAGUAcgBpAHMAawAgAFIARwBCAC0AcAByAG8AZgBpAGwAUAByAG8AZgBpAGwAIABHAOkAbgDpAHIAaQBxAHUAZQAgAFIAVgBCTgCCLAAgAFIARwBCACAw1zDtMNUwoTCkMOuQGnUoACAAUgBHAEIAIIJyX2ljz4/wAFAAZQByAG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AEcAQgAtAGIAZQBzAGsAcgBpAHYAZQBsAHMAZQBBAGwAZwBlAG0AZQBlAG4AIABSAEcAQgAtAHAAcgBvAGYAaQBlAGzHfLwYACAAUgBHAEIAINUEuFzTDMd8AFAAcgBvAGYAaQBsAG8AIABSAEcAQgAgAEcAZQBuAGUAcgBpAGMAbwBHAGUAbgBlAHIAaQBjACAAUgBHAEIAIABQAHIAbwBmAGkAbABlBB4EMQRJBDgEOQAgBD8EQAQ+BEQEOAQ7BEwAIABSAEcAQgBVAG4AaQB3AGUAcgBzAGEAbABuAHkAIABwAHIAbwBm/wBpAGwAIABSAEcAQgAAZGVzYwAAAAAAAAAUR2VuZXJpYyBSR0IgUHJvZmlsZQAAAAAAAAAAAAAAFEdlbmVyaWMgUkdCIFByb2ZpbGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABadQAArHMAABc0WFlaIAAAAAAAAPNSAAEAAAABFs9YWVogAAAAAAAAdE0AAD3uAAAD0FhZWiAAAAAAAAAoGgAAFZ8AALg2Y3VydgAAAAAAAAABAc0AAHRleHQAAAAAQ29weXJpZ2h0IDIwMDcgQXBwbGUgSW5jLkMsIGFsbCByaWdodHMgcmVzZXJ2ZWQuAHNmMzIAAAAAAAEMQgAABd7///MmAAAHkgAA/ZH///ui///9owAAA9wAAMBsACwAAAAACgAKAAAEJRBJREKZsxQDsCSGIVzZFnYTGIqktp7fG46uzAn2TAyCMPC9QAQAOw%3D%3D);15: }
source: http://jsfiddle.net/vojtajina/js64b/14/
table sorting–angularjs的更多相关文章
- 通过angularjs的directive以及service来实现的列表页加载排序分页
前两篇:(列表页的动态条件搜索,我是如何做列表页的)分别介绍了我们是如何做后端业务系统数据展示类的列表页以及动态搜索的,那么还剩下最重要的一项:数据展示.数据展示一般包含三部分: 数据列头 数据行 分 ...
- 通过angularjs的directive以及service来实现的列表页加载排序分页(转)
前两篇:(列表页的动态条件搜索,我是如何做列表页的)分别介绍了我们是如何做后端业务系统数据展示类的列表页以及动态搜索的,那么还剩下最重要的一项:数据展示.数据展示一般包含三部分: 数据列头 数据行 分 ...
- (三)Angularjs - 小实例
AngularJS处理数据表格 使用 np-repeat 指令 <table> ... <!-- 这里使用ng-repeat指令来重复数据生成表格 --> <tr ng- ...
- angularjs 常用功能练习
<!DOCTYPE html> <html ng-app="app"> <head> <meta charset="utf-8& ...
- hive-site.xml 参数设置
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="confi ...
- mysql实用指南
mysqld --verbose --help: 可以显示 mysql 的编译配置选项,即功能配置描述. mysql 的配置文件my.cnf调用次序(mysqld --verbose --help 的 ...
- Scope Directive
---------------------------Scope-------------------------------- https://docs.angularjs.org/guide/sc ...
- ng2-table
[转]https://github.com/valor-software/ng2-table demo:http://valor-software.com/ng2-table/ ng2-table ...
- drupal 用法小结,drupal select ,query ,distinct
https://api.drupal.org/api/drupal/includes%21actions.inc/function/actions_do/7.x addFileds : 这个更全点: ...
随机推荐
- JAVA教师:给JAVA初学者的忠告
我带过不少JAVA,C++班的课,来学习的同学很多都是初学者,一部分是急着找工作的,一部分是很感兴趣的.他们都想在短短一两个星期内掌握Java,这是不切实际的.而且这样做很容易让自己心浮气燥,难以静下 ...
- Mac 效率工具
我的Mac开发环境 http://blog.csdn.net/feelang/article/details/45071249 iterm2 http://iterm2.com/documentati ...
- XMPP开发环境配置
首先配置XMPP开发环境配置需要的软件 先安装xampp-osx-1.8.3-5-installer.dmg 安装成功后launchpad里会多出一个XAMPP(其他),点开里面的manager-os ...
- 什么叫session和cookie-及其设置
http的无状态? 保持状态, 是指当程序关闭后重启, 上一次操作的历史还能继续, 保持的. 如word中的 "选项"设置. 如windows系统的设置等等. http的设计目的, ...
- 日期控件jsdate用法注意事项
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js倒计时代码 适合于促销-倒计时代码
<div class="tiem_price clearfix fonts" style="margin-top:15px;"> <div c ...
- 2015-9月份,Android开发,面试题总结,主要记录没有答出来的问题
9月13日,秒针面试(跪) 1.使用HTML5写Android 与本地应用比较 9月21日,百度一面(跪)1.Android的整个启动过程,什么阶段启动了什么进程,或者服务 2.Android系统框架 ...
- 如何用angularjs给从后台传来数据添加链接
<!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="UTF- ...
- Hide JSP error icons in Eclipse
down voteaccepted Can can either configure this at workspace level or overwrite at web project level ...
- Ubuntu下三个实用的录屏软件
Ubuntu下三个实用的录屏软件 Kazam 优点: 易安装 可选择区域录制,也可全屏录制 有录屏和截图功能 安装: sudo apt-get install kazam 展示: Simple Scr ...