Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zui
提交
7b3b040b
Z
zui
项目概览
易企天创
/
zui
11 个月 前同步成功
通知
6
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
37
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
37
Issue
37
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7b3b040b
编写于
11月 14, 2014
作者:
C
Catouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* datatable support storage option and updated document.
上级
6e822105
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
22 deletion
+39
-22
docs/views.html
docs/views.html
+10
-0
src/js/datatable.js
src/js/datatable.js
+29
-22
未找到文件。
docs/views.html
浏览文件 @
7b3b040b
...
...
@@ -151,6 +151,16 @@ $('table.datatable').datatable({checkable: true, sortable: true});
<p>
仅在
<code>
checkable
</code>
选项为
<code>
true
</code>
时生效
</p>
</td>
</tr>
<tr>
<td><code>
storage
</code></td>
<td>
<ul>
<li><code>
false
</code></li>
<li><code>
true
</code>
(默认)
</li>
</ul>
</td>
<td>
是否启用本地存储来增强用户体验。启用该选项之后,表格排序状态及选中的行在用户刷新页面之后仍然会还原为之前的扎状态。
</td>
</tr>
<tr>
<td><code>
sortable
</code></td>
<td>
...
...
src/js/datatable.js
浏览文件 @
7b3b040b
...
...
@@ -53,6 +53,9 @@
// Sort options
sortable
:
false
,
// enable sorter
// storage
storage
:
true
,
// enable storage
// fixed header of columns
fixedHeader
:
true
,
// fixed header
fixedHeaderOffset
:
0
,
// set top offset of header when fixed
...
...
@@ -585,7 +588,7 @@
$datatable
.
toggleClass
(
'
scrolled-in
'
,
barLeft
>
2
)
.
toggleClass
(
'
scrolled-out
'
,
barLeft
<
flexWidth
-
scrollWidth
-
2
);
store
.
pageSet
(
scrollOffsetStoreName
,
barLeft
);
if
(
options
.
storage
)
store
.
pageSet
(
scrollOffsetStoreName
,
barLeft
);
};
var
resizeScrollbar
=
function
()
{
...
...
@@ -610,7 +613,7 @@
};
// $scrollbar.resize(resizeScrollbar); // todo: unuseful?
$flexArea
.
resize
(
resizeScrollbar
);
resizeScrollbar
();
if
(
options
.
storage
)
resizeScrollbar
();
var
dragOptions
=
{
move
:
false
,
...
...
@@ -667,7 +670,7 @@
});
$headSpans
.
find
(
'
.check-all
'
).
toggleClass
(
'
checked
'
,
checkedStatus
.
checkedAll
);
store
.
pageSet
(
checkedStatusStoreName
,
checkedStatus
);
if
(
options
.
storage
)
store
.
pageSet
(
checkedStatusStoreName
,
checkedStatus
);
that
.
callEvent
(
'
checksChanged
'
,
{
...
...
@@ -695,25 +698,28 @@
syncChecks
();
});
var
checkedStatus
=
store
.
pageGet
(
checkedStatusStoreName
);
if
(
checkedStatus
)
if
(
options
.
storage
)
{
$headSpans
.
find
(
'
.check-all
'
).
toggleClass
(
'
checked
'
,
checkedStatus
.
checkedAll
);
if
(
checkedStatus
.
checkedAll
)
var
checkedStatus
=
store
.
pageGet
(
checkedStatusStoreName
);
if
(
checkedStatus
)
{
$rows
.
addClass
(
checkedClass
);
}
else
{
$rows
.
removeClass
(
checkedClass
);
$
.
each
(
checkedStatus
.
checks
,
function
(
index
,
ele
)
$headSpans
.
find
(
'
.check-all
'
).
toggleClass
(
'
checked
'
,
checkedStatus
.
checkedAll
);
if
(
checkedStatus
.
checkedAll
)
{
$rows
.
filter
(
'
[data-id="
'
+
ele
+
'
"]
'
).
addClass
(
checkedClass
);
});
}
if
(
checkedStatus
.
checks
.
length
)
{
syncChecks
();
$rows
.
addClass
(
checkedClass
);
}
else
{
$rows
.
removeClass
(
checkedClass
);
$
.
each
(
checkedStatus
.
checks
,
function
(
index
,
ele
)
{
$rows
.
filter
(
'
[data-id="
'
+
ele
+
'
"]
'
).
addClass
(
checkedClass
);
});
}
if
(
checkedStatus
.
checks
.
length
)
{
syncChecks
();
}
}
}
}
...
...
@@ -764,9 +770,10 @@
// Sort table
DataTable
.
prototype
.
sortTable
=
function
(
$th
)
{
var
store
=
window
.
store
;
var
store
=
window
.
store
,
options
=
this
.
options
;
var
sorterStoreName
=
this
.
id
+
'
_datatableSorter
'
;
var
sorter
=
store
.
pageGet
(
sorterStoreName
)
;
var
sorter
=
options
.
storage
?
store
.
pageGet
(
sorterStoreName
)
:
null
;
if
(
!
$th
)
{
...
...
@@ -872,7 +879,7 @@
};
// save sort with local storage
store
.
pageSet
(
sorterStoreName
,
sorter
);
if
(
options
.
storage
)
store
.
pageSet
(
sorterStoreName
,
sorter
);
this
.
callEvent
(
'
sort
'
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录