jquery dataTables例子
https://datatables.net/examples/styling/bootstrap.html
http://datatables.club/example/#styling
http://blog.csdn.net/hefangju/article/details/50333609'
http://www.cnblogs.com/Leo_wl/p/4289289.html
http://www.guoxk.com/node/jquery-datatables
http://stackoverflow.com/questions/11011796/trying-to-custom-style-datatables-table
http://stackoverflow.com/questions/5509303/customized-table-style-when-using-jquery-datatables
ajax:
https://datatables.net/manual/server-side
https://datatables.net/examples/data_sources/server_side.html
return:
draw |
integer |
The draw counter that this object is a response to - from the draw parameter sent as part of the data request. Note that it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply echoing back to the client what it sent in the draw parameter, in order to prevent Cross Site Scripting (XSS) attacks. |
recordsTotal |
integer |
Total records, before filtering (i.e. the total number of records in the database) |
recordsFiltered |
integer |
Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data). |
data |
array |
The data to be displayed in the table. This is an array of data source objects, one for each row, which will be used by DataTables. Note that this parameter's name can be changed using the ajax option's dataSrc property. |
error |
string |
Optional: If an error occurs during the running of the server-side processing script, you can inform the user of this error by passing back the error message to be displayed using this parameter. Do not include if there is no error. |
laravel eloquent limit offset
$users = DB::table('users')->skip(10)->take(5)->get();
https://laravel-china.org/docs/5.1/queries#ordering-grouping-limit-and-offset
ajax例子:
https://coderexample.com/jquery-datatable-with-custom-json-format-in-php-mysql
columndefs:
https://datatables.net/reference/option/columnDefs
targets:
- 0 or a positive integer - column index counting from the left
- A negative integer - column index counting from the right
- A string - class name will be matched on the TH for the column
- The string
_all- all columns (i.e. assign a default)
targets也可以是一个数组。
targets: [ -1, -2 ] would target the last and second last columns in the table.
var table = $('#myTable').DataTable( {
columnDefs: [ { targets: [0, 1], visible: true}, { targets: '_all', visible: false } ]} );columns
这个指定了传过来的数据的字段,visible字段默认是true,如果设置false的话,显示的时候是隐藏的,当然也可以通过空间取消其隐藏。 发现columns不仅传给服务器,客户端也会用到。
columns:[
{data:"name_id"},
{data:"id",},
我把name_id和id调换,值也会调换。
设置某列宽度
columns:[
{data:"id",width:'50%',},
还可以在columns设置orderorderable: false ,
columns会传给服务器。
post给服务器的类似:
..
- columns[5][data]:status
- columns[5][name]:
- columns[5][searchable]:true
- columns[5][orderable]:true
- columns[5][search][value]:
- columns[5][search][regex]:false
- columns[6][data]:created_at
- columns[6][name]:
- columns[6][searchable]:true
- columns[6][orderable]:false
- columns[6][search][value]:
- columns[6][search][regex]:false
- order[0][column]:0
- order[0][dir]:asc
- start:0
- length:5
- search[value]:
- search[regex]:false
$('#example').dataTable( {
"columnDefs": [ { className: "my_class", "targets": [ 0 ] } ]} );$('#datatable_demo').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "server-json-data.php",
"type": "POST",
"dataSrc": "records"
},
"columns": [
{ "data": "invoice_no" }, 、、这里data返回指定的列名 ,如果默认可以写为null.
{ "data": "product_name" },
{ "data": "delivery_status" },
{ "data": "pin_code" },
],
"columnDefs": [
{
"targets": 2,
"render": function ( data, type, row,meta ) {
return data == 1 ? 'Delivered': 'Not delivered';
}
},
{
"targets": 3,
"render": function ( data, type, row ,meta) {
return row["city"] +', ' + row["country"] +', '+data;
},
},
]
});
$('#example').dataTable( {
"columns": [
{ "searchable": false },
null,
null,
null,
null
]
} );
禁止sort:
columnDefs:[
// {targets:0,visible:false},
{
targets:-2,
render:function(data,type,row,meta){
if(data==1)
return "<span class='label label-success radius'>正常</span>";
return "<span class='label label-danger radius'>维护</span>"; }
},
{
targets:[1,2,3], orderable: false
}, ]
交互式:
https://coderexample.com/datatable-responsive-server-side/
reload:
https://datatables.net/reference/api/ajax.reload()
Send request as POST:
Javascript
$('#example').dataTable( {
"ajax": {
"url": "data.json",
"type": "POST"
}
} );
Add data to the request, returnng an object by extending the default data:
$('#example').dataTable( {
"ajax": { "url": "data.json", "data": function ( d ) { return $.extend( {}, d, { "extra_search": $('#extra').val() } ); } }} );function datatablessearch()
{
datableCurr.ajax.reload();
}
dataableCurr能用ajax,要注意是大写的DataTable()调用得到DataTables对象,否则用小写dataTable()得到的是juqery对象,没有ajax方法。
$( selector ).DataTable();- DataTables constructor$( selector ).dataTable().api();- DataTables jQuery constructor
jquery dataTables例子的更多相关文章
- jquery.dataTables插件使用例子详解
DataTables是一个jQuery的表格插件.这是一个高度灵活的工具,依据的基础逐步增强,这将增加先进的互动控制,支持任何HTML表格 效果图 代码 <!doctype html> & ...
- jQuery datatables
jQuery datatables 属性,用例 参考:http://datatables.club/example/ http://blog.csdn.net/mickey_miki/article/ ...
- jquery datatables api (转)
学习可参考:http://www.guoxk.com/node/jquery-datatables http://yuemeiqing2008-163-com.iteye.com/blog/20069 ...
- 最全的jquery datatables api 使用详解
学习可参考:http://www.guoxk.com/node/jquery-datatables http://yuemeiqing2008-163-com.iteye.com/blog/20069 ...
- jquery datatables api
原文地址 学习可参考:http://www.guoxk.com/node/jquery-datatables http://yuemeiqing2008-163-com.iteye.com/blog/ ...
- jquery.dataTables的用法
写页面前端时,使用表格的插件可以快速漂亮的排版.本例子中使用jquery.dataTables来处理table.直接来点干货 html代码如下 <table cellpadding=" ...
- jquery datatables 学习笔记
最近项目中用到了BootStrap做后台,在选择表格插件的时候发现了jquery datatables. 功能是很强大,但是网上的例子比较少.在经过一段时间的努力可算是搞出来了. 官网地址:http: ...
- Jquery DataTables 自定义布局sdom
Jquery DataTables 自定义布局sdom JQuery Datatable sDom 配置 官网给的描述是: This initialisation variable allows yo ...
- [jQuery]jQuery DataTables插件自定义Ajax分页实现
前言 昨天在博客园的博问上帮一位园友解决了一个问题,我觉得有必要记录一下,万一有人也遇上了呢. 问题描述 园友是做前端的,产品经理要求他使用jQuery DataTables插件显示一个列表,要实现分 ...
随机推荐
- 关于启动VS2012时,提示Web4.0尚未在网络服务器上注册的解决办法!
VS2012在没有Web服务器上注册的问题,网上有很多博客. 开始我就是遇到这个问题,在网上试了几个办法,确实都还可以.但是相比之下有的需要设置DOS,进行安装.exe. 这种方法其实相比直接安装补丁 ...
- MS14-064 漏洞测试入侵——20145301
MS14-064 漏洞测试入侵 Microsoft Windows OLE远程代码执行漏洞,OLE(对象链接与嵌入)是一种允许应用程序共享数据和功能的技术 执行摘要 此安全更新可解决 Microsof ...
- XmlHelpers
最近处理数据的时候用到了Xml和其他数据之间的转换,所以整理了一些方法. class XMLHelper { /// <summary> /// 读取xml模板 /// </summ ...
- [No0000EA]C# 可空类型(Nullable)
C# 可空类型(Nullable) C# 提供了一个特殊的数据类型,nullable 类型(可空类型),可空类型可以表示其基础值类型正常范围内的值,再加上一个 null 值. 例如,Nullable& ...
- 【每日一题】 uva-232 模拟+输出要求很严格
https://cn.vjudge.net/problem/UVA-232 uva的题,结尾不能多\n,空格什么的 反正就是个中型模拟,题目多读就行 #define _CRT_SECURE_NO_WA ...
- 理解套接字Socket
Socket 在应用层和传输层之间的一个抽象层,它把TCP/IP层复杂的操作抽象为几个简单的接口供应用层调用以实现进程在网络中通信. 需要记住的知识点: 监听的 Socket 和真正用来传数据的 So ...
- NodeJS websocket qr based on location
https://juejin.im/post/5a5728436fb9a01c982c7d93 http://www.cnblogs.com/panhe-xue/p/5902108.html---br ...
- java string和int之间的相互转化
java 中string和int之间的相互转化 1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); ...
- LeetCode 590 N-ary Tree Postorder Traversal 解题报告
题目要求 Given an n-ary tree, return the postorder traversal of its nodes' values. 题目分析及思路 题目给出一棵N叉树,要求返 ...
- linux strncpy()和strcat使用总结
strcat原型:char *strcat(char *dest,const char *src); 把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'.src和de ...