首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-11-09 
JQuery Datatables 学习笔记(二)-customer set the option at inint timereview:上一节,简要描叙了DT的作

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

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,然后用新的参数构建一个新的)

?

?

??

?

热点排行