JQuery Datatables 学习笔记(二)-customer set the option at inint time

本文介绍了 DataTables 的核心配置选项,包括排序、过滤、显示长度及页面布局等,帮助用户快速掌握如何根据需求定制表格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

review:上一节,简要描叙了DT的作用,如何插入到页面当中,基本功能构造,etc。这一节主要围绕基本功能,用户配置适合自己的相关参数满足需要。

1、排序方面:(bSort)

when bSort Set be true,可以在初始表格时,指定哪些列如何排序,以及排序的方向,通过aaSorting这个property可以实现

$("#tableid").dataTable({"bSort":true,"aaSorting":[[0,"asc"][1,"desc"]]});

 表格初始化时先对第一行升序排,然后第二行降序排.

2、Filter方面

过滤,即find.初始化时pass a keywords to filter the table.使用aoSearchCols和oSearch两个参数定义.

oSearch站在全局的高度搜索,而aSearchCols是对ividial column define。例子

$("#tableid").dataTable({
"bFilter":true,
"oSearch":{"sSearch":"keyword1 keyword2 keyword3 ...","bRegex":true}
})

 sSearch:must provide.

bRegex:false|true(optional)

上面执行结果是在初始化时datatable查找key1,key2,key3...

$("#tableid").dataTable({
"aoSearchCols":[null,
{"sSearch":"keyword","bRegex":true}
null,
{"sSearch":"keyword2",bRegex":false}
]});

 aoSearchCols更像是aoColumns的定义,用于初始化时定义单列的查找关键字,注意:aoSearchCols数组长度必须和表格列数相同。

3、每页显示长度下拉列表框(bLengthChange)/分页符(bPaginate)

     iDisplayLenth:初始化时一页显示的列数(10,25,50,75,100,125,...-1)

     iDisplayStart:record offset,第一行显示的行数,默认情况是第一行。。。。

     aLengthMenu:定义下拉列表框的value和option。可以是1D,alse 2D<select><option></option></select>

    

$("#tableid").dataTable({
"iDispalyLenth":-1,//显示所有的记录.
"iDisplayStart":50,//从第50行开始显示.
"aLengthMenu":[-1,10,25,50]["all","十","二十五","五十"],
"sPagination":"two_button"|"full_numbers"
})

4、页面布局(sDom)

sDom:"<""flipt>', 'ip>'"

The following options are allowed:
  • 'l' - Length changing //下拉列表框(长度 )
  • 'f' - Filtering input //搜索框
  • 't' - The table! //表格数据
  • 'i' - Information //information
  • 'p' - Pagination //分页表
  • 'r' - pRocessing //进度条
The following constants are allowed: 在JQueryUI中使用
  • 'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix') //表格头
  • 'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix') //表尾

 

The following syntax is expected:
  • '<' and '>' - div elements //使用div
  • '<"class" and '>' - div with a class //使用类

4、其他方面

.bDestroy(删除匹配原先的DT,然后用新的参数构建一个新的)

 

 

  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值