dataTable.NET是一個jQuery的plug in 第三方的library, 用來實現web page中table的interaction controls, 另外最近有在用的還有Telerik UI的RadGrid(action需要postback).

dataTable.NET可以通過簡單的setting,使已經define好的table columns調整顯示的順序或是隱藏,還可以對單個或多個columns進行sort.

在使用過程中有遇到一些有趣的狀況。

<table id="test-listing">
<thead>
<tr>
<th>column0</th>
<th>column1</th>
<th>column2</th>
<th>column3</th>
<th>column4</th>
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
...
</tr>
...
</tbody>
</table>

以上面的table為例,當需要在顯示時對columns重新排序,並且隱藏某些columns時

$('#test-listing').DataTable({
paging: false,
ordering: true,
fixedHeader: true,
columnDefs: [3,1,4,2,0],
colReorder: {
order: [{"visible":false, "target":2}],
enable: false
},
"search": {
"search": "xxxx"
},
order: [[4, "asc"]],
"dom":
"<'row'f>" +
"<'row dt-table'" +
"<'sixteen wide column'tr>" +
">" +
"<'row'i>"
});

上面的setting,顯示在頁面上的結果

column3 column1 column4 column0
       

以column4升序排列。在setting中用到index為初始在頁面中定義的column的index。

當table已經load結束,可以使用下面的方法獲取當前的排序:

var table = $('#test-listing').dataTable();
var currentSort = table.fnSettings().aaSorting;

得到的sort會是以當前顯示的colums的index為準,[[2, "asc"]]

如果需要將抓到的當前sort存至cookie,下次頁面顯示時做為setting使用的話,記得先做轉換處理。

dataTable.NET的column index的不同定義的更多相关文章

  1. java.sql.SQLException:Column Index out of range,0<1

    1.错误描述 java.sql.SQLException:Column Index out of range,0<1 2.错误原因 try { Class.forName("com.m ...

  2. Column Index out of range, 2 > 1 列索引的范围,2 > 1。

    Column Index out of range, 2 > 1  列索引的范围,2 > 1.这个问题是进行数据库查询的时候出现的. 因为查询sql语句时 只查询了 name 然后whil ...

  3. 表结构变更后出现的ERROR OGG-01161 Bad column index (88)

    2014-07-31 09:38:31 ERROR OGG-01668 PROCESS ABENDING. 2014-07-31 09:38:31 ERROR OGG-01161 Bad column ...

  4. Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错

    做模糊搜索时,出现了  bind or column index out of range: handle 0x2fb180 报错 public Cursor getTitle(String word ...

  5. Neo4j中實現自定義中文全文索引

    資料庫檢索效率時,一般首要優化途徑是從索引入手,然後根據需求再考慮更復雜的負載均衡.讀寫分離和分散式水平/垂直分庫/表等手段:索引通過資訊冗餘來提高檢索效率,其以空間換時間並會降低資料寫入的效率,因此 ...

  6. #HTML:無序、有序與定義清單

    #HTML:無序.有序與定義清單 Maplewing 于 星期六, 12/10/2013 - 09:48 提交 清單在網頁中是很常使用到的東西,故多少還是要了解一下.在HTML中有三種不太一樣的清單, ...

  7. Q郵箱轉移自定義目錄中的郵件

    1.之前在Q郵箱上建立了許多規則和收件箱,現在想統一用Mac上的郵局管理 2.Mac上會同步對應郵箱的自定義目錄,此時這些目錄便十分多餘礙眼 3.Q郵箱單頁顯示郵件數量上限是100,這意味著手動轉移十 ...

  8. 可以支持jQuery1.10.1 的 fancybox 1.3.4, 並現在type為Ajax時,也可以定義窗口的大小。

    官網上的 fancybox 1.3.4 太老了,不支持jQuery1.10.1,改動了一下源碼,現在可以支持了. type為Ajax時,也可以定義窗口的大小. $("#ajaxlink&qu ...

  9. Linux Ubuntu 虛擬機系統自定義桌面分辨率且重啓後保持不變

    我用 VMware Workstation 12 Pro 安裝的 Ubuntu MATE Desktop Environment 1.12.1,發現安裝後沒有需要的分辨率,於是安裝 VMware To ...

随机推荐

  1. 使用Arduino和SD卡模块记录数据并导出到Excel

    在本篇文章中,我们将学习如何基于Arduino开发板使用一个SD卡模块.同时结合DS3231实时时钟模块,我们将制作一个数据记录仪的示例,在示例中,我们将温度传感器的数据存储到SD卡中,并将这些数据导 ...

  2. django项目简单调取百度翻译接口

    1,建路由: 2,写方法: def fanyi(request): import requests import json content = request.POST.get('content') ...

  3. java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.

    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha ...

  4. UVA - 12183 :Top Secret(N^2的循环矩阵乘法)

    pro:N个数排成一圈.一次操作为,每个位置的数+=L*左+R*右,保留x为整数. 问S轮操作后每个位置的值. N<=1000,S<=2^30,x<=9 . sol:不难想到矩阵乘法 ...

  5. centos7安装yum安装pip

    pip是python中的一个包管理工具,可以对Python包的查找.下载.安装.卸载的作用. yum -y install epel-release yum -y install python-pip ...

  6. django-提交订单

    购物车cart.html页面加form表单提交 <form method="post" action="{% url 'order:place' %}"& ...

  7. STM32L4R9使用HAL库调试IIC注意事项

    STM32使用Cubemx生成的代码中,用到IIC的驱动,但是始终不能读写,因此使用逻辑分析仪,发现原本地址为0x58的写成了0x20,因此肯定是地址错了.因此,总结如下: 1.需要逻辑分析仪分析II ...

  8. C define详解

    1.简单的define定义 #define MAXTIME 1000 一个简单的MAXTIME就定义好了,它代表1000,如果在程序里面写 if(i<MAXTIME){.........} 编译 ...

  9. 【洛谷P2664】 树上游戏 点分治

    code: #include <bits/stdc++.h> #define N 200009 #define ll long long #define setIO(s) freopen( ...

  10. learning scala someElements

    The Scala collections library provides specialised implementations for Sets of fewer than 5 values ( ...