提交 c1997eb7 编写于 作者: C Catouse

* fixed errors in datatable.

 * updated document.
上级 c3e47472
......@@ -4597,11 +4597,11 @@ var imgReady = (function () {
rowCol = row.data[i];
if(!$.isPlainObject(rowCol))
{
rowCol = {text: rowCol};
rowCol = {text: rowCol, row: r, index: i};
row.data[i] = rowCol;
}
td = '<td data-index="' + i + '" data-flex="false" data-type="' + cols[i].type + '" class="' + (rowCol.cssClass || '') + ' ' + (cols[i].colClass || '') + '" style="' + (rowCol.css || '') + '">' + rowCol.text + '</td>';
td = '<td data-row="' + r + '" data-index="' + i + '" data-flex="false" data-type="' + cols[i].type + '" class="' + (rowCol.cssClass || '') + ' ' + (cols[i].colClass || '') + '" style="' + (rowCol.css || '') + '">' + rowCol.text + '</td>';
if(i == 0 && options.checkable)
{
td = '<td data-index="check" class="check-row check-btn"><i class="icon-check-empty"></i></td>' + td;
......@@ -4847,10 +4847,10 @@ var imgReady = (function () {
navbarHeight = options.fixedHeaderOffset || $('.navbar.navbar-fixed-top').height() || 0;
var handleScroll = function()
{
scrollTop = $(window).scrollTop();
offsetTop = $datatable.offset().top;
scrollTop = $(window).scrollTop();
height = $datatable.height();
$datatable.toggleClass('head-fixed', scrollTop > offsetTop && scrollTop < (offsetTop + height));
$datatable.toggleClass('head-fixed', (scrollTop + navbarHeight) > offsetTop && (scrollTop + navbarHeight) < (offsetTop + height));
if($datatable.hasClass('head-fixed'))
{
$dataTableHead.css(
......@@ -4869,6 +4869,7 @@ var imgReady = (function () {
handleScroll();
}
// make sortable
if(options.sortable)
{
var $th, sortdown;
......@@ -4878,6 +4879,8 @@ var imgReady = (function () {
});
}
//
this.refresh();
};
......@@ -4933,11 +4936,13 @@ var imgReady = (function () {
}
});
var valA, valB, result;
var valA, valB, result, $dataRows = this.$dataCells.filter('[data-index="' + index + '"]');
rows.sort(function(cellA, cellB)
{
valA = cellA.data[index].text;
valB = cellB.data[index].text;
cellA = cellA.data[index];
cellB = cellB.data[index];
valA = $dataRows.filter('[data-row="' + cellA.row + '"]').text();
valB = $dataRows.filter('[data-row="' + cellB.row + '"]').text();
if(type === 'number')
{
valA = parseFloat(valA);
......@@ -4979,9 +4984,9 @@ var imgReady = (function () {
// save sort with local storage
store.pageSet(sorterStoreName, {index: index, type: sortUp ? 'up' : 'down'});
}
};
DataTable.prototype.refresh = function()
DataTable.prototype.refreshSize = function()
{
var $datatable = this.$datatable,
options = this.options,
......@@ -4995,7 +5000,11 @@ var imgReady = (function () {
{
$cells.filter('[data-index="' + i + '"]').css('width', cols[i].width);
}
};
DataTable.prototype.refresh = function()
{
this.refreshSize();
this.sortTable();
}
......
此差异已折叠。
......@@ -257,7 +257,7 @@ $(function()
{
cols:
[
{sort: 'up', width: 80, text: '#', type: 'number', flex: false, colClass: 'text-center', css: 'color: #444'},
{sort: 'down', width: 80, text: '#', type: 'number', flex: false, colClass: 'text-center', css: 'color: #444'},
{width: 'auto', text: 'Name', type: 'string', flex: false},
{width: 100, text: 'Mood', type: 'string', flex: false},
{width: 150, text: 'Date', type: 'date', flex: true, cssClass: 'text-center'},
......@@ -267,14 +267,14 @@ $(function()
],
rows:
[
{checked: false, data: ['1', 'Catouse', 'happy', '2014-08-07', 'null is good', '1', 'OK']},
{checked: true, data: ['2', 'Shine', 'angry', '2014-08-06', 'god is girl', '2', 'OK']},
{checked: false, data: ['3', 'Minus', 'Veritatis', '2014-08-07', 'Nulla', '1', 'Ipsam']},
{cssClass:'danger', checked: false, data: ['4', 'Consequatur', 'Accusamus', '2014-08-07', 'Obcaecati', '1', 'Qui']},
{checked: false, data: ['5', 'Lorem', 'Quos', '2014-08-07', 'Molestiae', '1', 'Qui']},
{checked: false, data: ['6', 'Suscipit', 'Vitae', '2014-08-07', 'Suscipit', '1', 'AE']},
{checked: false, data: ['7', 'Vel', 'Blanditiis', '2014-08-07', 'Aspernatur', '1', 'Sed']},
{checked: false, data: ['8', 'Vero', 'Officiis', '2014-08-07', 'Quos', '1', 'Vel']}
{checked: false, data: ['1', '<a href="###">Catouse</a>', 'happy', '2014-08-07', 'null is good', '1', 'OK']},
{checked: true, data: ['2', '<a data="fd" href="###">Shine</a>', 'angry', '2014-08-06', 'god is girl', '2', 'OK']},
{checked: false, data: ['3', '<a href="###">Minus</a>', 'Veritatis', '2014-08-07', 'Nulla', '1', 'Ipsam']},
{cssClass:'danger', checked: false, data: ['4', '<a href="###">Consequatur</a>', 'Accusamus', '2014-08-07', 'Obcaecati', '1', 'Qui']},
{checked: false, data: ['5', '<a href="###">Lorem</a>', 'Quos', '2014-08-07', 'Molestiae', '1', 'Qui']},
{checked: false, data: ['6', '<a href="###">Suscipit</a>', 'Vitae', '2014-08-07', 'Suscipit', '1', 'AE']},
{checked: false, data: ['7', '<a href="###">Vel</a>', 'Blanditiis', '2014-08-07', 'Aspernatur', '1', 'Sed']},
{checked: false, data: ['8', '<a href="###">Vero</a>', 'Officiis', '2014-08-07', 'Quos', '1', 'Vel']}
]
}
});
......
......@@ -95,7 +95,7 @@ $(function()
var ver = $this.data('version') + '';
if(versionToNumber(ver) > versionNum)
{
$this.children('.page-header').children('h2').append(' <small class="label label-warning" title="" data-original-title="此内容正在开发中">DEV</small>');
$this.children('.page-header').children('h2').append(' <small class="label label-warning" title="" data-original-title="此内容正在开发中,将在v' + ver + '中提供">DEV</small>');
}
});
......
......@@ -283,11 +283,11 @@
rowCol = row.data[i];
if(!$.isPlainObject(rowCol))
{
rowCol = {text: rowCol};
rowCol = {text: rowCol, row: r, index: i};
row.data[i] = rowCol;
}
td = '<td data-index="' + i + '" data-flex="false" data-type="' + cols[i].type + '" class="' + (rowCol.cssClass || '') + ' ' + (cols[i].colClass || '') + '" style="' + (rowCol.css || '') + '">' + rowCol.text + '</td>';
td = '<td data-row="' + r + '" data-index="' + i + '" data-flex="false" data-type="' + cols[i].type + '" class="' + (rowCol.cssClass || '') + ' ' + (cols[i].colClass || '') + '" style="' + (rowCol.css || '') + '">' + rowCol.text + '</td>';
if(i == 0 && options.checkable)
{
td = '<td data-index="check" class="check-row check-btn"><i class="icon-check-empty"></i></td>' + td;
......@@ -533,10 +533,10 @@
navbarHeight = options.fixedHeaderOffset || $('.navbar.navbar-fixed-top').height() || 0;
var handleScroll = function()
{
scrollTop = $(window).scrollTop();
offsetTop = $datatable.offset().top;
scrollTop = $(window).scrollTop();
height = $datatable.height();
$datatable.toggleClass('head-fixed', scrollTop > offsetTop && scrollTop < (offsetTop + height));
$datatable.toggleClass('head-fixed', (scrollTop + navbarHeight) > offsetTop && (scrollTop + navbarHeight) < (offsetTop + height));
if($datatable.hasClass('head-fixed'))
{
$dataTableHead.css(
......@@ -555,6 +555,7 @@
handleScroll();
}
// make sortable
if(options.sortable)
{
var $th, sortdown;
......@@ -564,6 +565,8 @@
});
}
//
this.refresh();
};
......@@ -619,11 +622,13 @@
}
});
var valA, valB, result;
var valA, valB, result, $dataRows = this.$dataCells.filter('[data-index="' + index + '"]');
rows.sort(function(cellA, cellB)
{
valA = cellA.data[index].text;
valB = cellB.data[index].text;
cellA = cellA.data[index];
cellB = cellB.data[index];
valA = $dataRows.filter('[data-row="' + cellA.row + '"]').text();
valB = $dataRows.filter('[data-row="' + cellB.row + '"]').text();
if(type === 'number')
{
valA = parseFloat(valA);
......@@ -665,9 +670,9 @@
// save sort with local storage
store.pageSet(sorterStoreName, {index: index, type: sortUp ? 'up' : 'down'});
}
};
DataTable.prototype.refresh = function()
DataTable.prototype.refreshSize = function()
{
var $datatable = this.$datatable,
options = this.options,
......@@ -681,7 +686,11 @@
{
$cells.filter('[data-index="' + i + '"]').css('width', cols[i].width);
}
};
DataTable.prototype.refresh = function()
{
this.refreshSize();
this.sortTable();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册