提交 263a7ec2 编写于 作者: C Catouse

* fixed height of head when fixed.

 * update data when check status changed.
上级 92f0517d
此差异已折叠。
/*!
* ZUI - v1.1.0 - 2014-08-06
* ZUI - v1.1.0 - 2014-08-11
* http://zui.sexy
* GitHub: https://github.com/easysoft/zui.git
* Copyright (c) 2014 cnezsoft.com; Licensed MIT
......@@ -70,13 +70,13 @@ if (typeof jQuery === "undefined") { throw new Error("ZUI requires jQuery") }
Store.prototype.pageGet = function(key, defaultValue)
{
var val = this.page[key];
return (defaultValue !== undefined && val === null) ? defaultValue : val;
return (defaultValue !== undefined && (val === null || val === undefined)) ? defaultValue : val;
};
/* Set page data */
Store.prototype.pageSet = function(objOrKey, val)
{
if($.isPlanObject(objOrKey))
if($.isPlainObject(objOrKey))
{
$.extend(true, this.page, objOrKey);
}
......@@ -129,7 +129,7 @@ if (typeof jQuery === "undefined") { throw new Error("ZUI requires jQuery") }
Store.prototype.get = function(key, defaultValue)
{
var val = this.deserialize(this.getItem(key));
return (defaultValue !== undefined && val === null) ? defaultValue : val;
return (defaultValue !== undefined && (val === null || val === undefined)) ? defaultValue : val;
};
/* Get item key by index and deserialize it */
......
此差异已折叠。
此差异已折叠。
......@@ -249,9 +249,10 @@
<script>
$(function()
{
$('#datatable').datatable();
$('#datatable').datatable({fixedHeaderOffset: 41});
$('#dtFromData').datatable
({
fixedHeaderOffset: 41,
data:
{
cols:
......
......@@ -34,6 +34,7 @@
DataTable.DEFAULTS =
{
fixedHeader : true,
// fixedHeaderOffset: 41, // set top offset of header when fixed
checkable : true,
checkByClickRow: true,
checkSingleByClickRow: true,
......@@ -235,8 +236,12 @@
row = rows[r];
cssClass = row.cssClass || '';
if(row.checked) cssClass += ' ' + (options.checkedClass || '');
if(typeof row.id === 'undefined')
{
row.id = r;
}
tr = '<tr class="' + cssClass + '" data-index="' + r + '" data-id="' + (row.id || r) + '">';
tr = '<tr class="' + cssClass + '" data-index="' + r + '" data-id="' + row.id + '">';
leftHtml += tr;
rightHtml += tr;
flexHtml += tr;
......@@ -309,6 +314,7 @@
// bind events
var options = this.options,
self = this,
data = this.data,
$cells = this.$cells,
$dataCells = this.$dataCells,
$headCells = this.$headCells,
......@@ -430,7 +436,8 @@
if(options.checkable)
{
var checkedStatusStoreName = self.id + '_' + checkedStatus,
checkedClass = options.checkedClass;
checkedClass = options.checkedClass,
rowId;
var syncChecks = function()
{
var $rows = self.$rowsSpans.first().find('.table > tbody > tr');
......@@ -438,8 +445,16 @@
var checkedStatus =
{
checkedAll: $rows.length === $checkedRows.length && $checkedRows.length > 0,
checks: $checkedRows.map(function(){return $(this).data('id')}).toArray()
checks: $checkedRows.map(function()
{
rowId = $(this).data('id');
return rowId;
}).toArray()
};
$.each(data.rows, function(index, value)
{
value.checked = ($.inArray(value.id, checkedStatus.checks) > -1);
});
self.$headSpans.find('.check-all').toggleClass('checked', checkedStatus.checkedAll);
store.pageSet(checkedStatusStoreName, checkedStatus);
......@@ -483,10 +498,9 @@
height,
scrollTop,
$dataTableHead = $datatable.children('.datatable-head'),
navbarHeight = $('.navbar.navbar-fixed-top').height() || 0;
navbarHeight = options.fixedHeaderOffset || $('.navbar.navbar-fixed-top').height() || 0;
var handleScroll = function()
{
console.log(navbarHeight);
scrollTop = $(window).scrollTop();
offsetTop = $datatable.offset().top;
height = $datatable.height();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册