diff --git a/lib/tabulator.css b/lib/tabulator.css
index 492a056..4155ede 100644
--- a/lib/tabulator.css
+++ b/lib/tabulator.css
@@ -1,4 +1,4 @@
-/* Tabulator v3.4.4 (c) Oliver Folkerd */
+/* Tabulator v3.5.0 (c) Oliver Folkerd */
.tabulator {
position: relative;
border: 1px solid #999;
diff --git a/lib/tabulator.js b/lib/tabulator.js
index 8d5b5aa..8533dab 100644
--- a/lib/tabulator.js
+++ b/lib/tabulator.js
@@ -2,7 +2,7 @@
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-/* Tabulator v3.4.4 (c) Oliver Folkerd */
+/* Tabulator v3.5.0 (c) Oliver Folkerd */
/*
* This file is part of the Tabulator package.
@@ -565,6 +565,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this._moveColumnInArray(this.columnsByIndex, from, to, after, true);
+ if (this.table.options.responsiveLayout && this.table.extExists("responsiveLayout", true)) {
+
+ this.table.extensions.responsiveLayout.initialize();
+ }
+
if (this.table.options.columnMoved) {
this.table.options.columnMoved(from.getComponent(), this.table.columnManager.getComponents());
@@ -713,7 +718,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.table.extExists("columnCalcs")) {
- this.table.extensions.columnCalcs.recalc(this.table.rowManager.displayRows);
+ this.table.extensions.columnCalcs.recalc(this.table.rowManager.activeRows);
}
this.redraw();
@@ -813,7 +818,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.table.extExists("columnCalcs")) {
- this.table.extensions.columnCalcs.recalc(this.table.rowManager.displayRows);
+ this.table.extensions.columnCalcs.recalc(this.table.rowManager.activeRows);
}
if (force) {
@@ -1092,6 +1097,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (typeof tooltip == "function") {
tooltip = tooltip(self.getComponent());
+
+ if (tooltip === false) {
+
+ tooltip = "";
+ }
}
self.element.attr("title", tooltip);
@@ -1376,16 +1386,23 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
table.extensions.accessor.initializeColumn(self);
}
+ //set respoviveLayout
+
+ if (_typeof(table.options.responsiveLayout) && table.extExists("responsiveLayout")) {
+
+ table.extensions.responsiveLayout.initializeColumn(self);
+ }
+
//set column visibility
if (typeof def.visible != "undefined") {
if (def.visible) {
- self.show();
+ self.show(true);
} else {
- self.hide();
+ self.hide(true);
}
}
@@ -1797,7 +1814,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
//show column
- Column.prototype.show = function () {
+ Column.prototype.show = function (silent, responsiveToggle) {
if (!this.visible) {
@@ -1821,18 +1838,26 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
cell.show();
});
- if (this.table.options.persistentLayout && this.table.extExists("persistence", true)) {
+ if (this.table.options.persistentLayout && this.table.extExists("responsiveLayout", true)) {
this.table.extensions.persistence.save("columns");
}
- this.table.options.groupVisibilityChanged(this.getComponent(), true);
+ if (!responsiveToggle && this.table.options.responsiveLayout && this.table.extExists("responsiveLayout", true)) {
+
+ this.table.extensions.responsiveLayout.updateColumnVisibility(this, this.visible);
+ }
+
+ if (!silent) {
+
+ this.table.options.columnVisibilityChanged(this.getComponent(), true);
+ }
}
};
//hide column
- Column.prototype.hide = function () {
+ Column.prototype.hide = function (silent, responsiveToggle) {
if (this.visible) {
@@ -1861,7 +1886,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.extensions.persistence.save("columns");
}
- this.table.options.groupVisibilityChanged(this.getComponent(), false);
+ if (!responsiveToggle && this.table.options.responsiveLayout && this.table.extExists("responsiveLayout", true)) {
+
+ this.table.extensions.responsiveLayout.updateColumnVisibility(this, this.visible);
+ }
+
+ if (!silent) {
+
+ this.table.options.columnVisibilityChanged(this.getComponent(), false);
+ }
}
};
@@ -2306,7 +2339,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.scrollToRow = function (row) {
- var rowIndex = this.displayRows.indexOf(row);
+ var rowIndex = this.getDisplayRows().indexOf(row);
if (rowIndex > -1) {
@@ -2361,14 +2394,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
data.forEach(function (def, i) {
- var row = new Row(def, self);
+ if (def && (typeof def === 'undefined' ? 'undefined' : _typeof(def)) === "object") {
+
+ var row = new Row(def, self);
- self.rows.push(row);
+ self.rows.push(row);
+ } else {
+
+ console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but receved:", def);
+ }
});
self.table.options.dataLoaded(data);
- self.refreshActiveData(true);
+ self.refreshActiveData();
} else {
console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", typeof data === 'undefined' ? 'undefined' : _typeof(data), "\nData: ", data);
@@ -2378,13 +2417,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.deleteRow = function (row) {
var allIndex = this.rows.indexOf(row),
- activeIndex = this.activeRows.indexOf(row),
- displayIndex = this.displayRows.indexOf(row);
-
- if (displayIndex > -1) {
-
- this.displayRows.splice(displayIndex, 1);
- }
+ activeIndex = this.activeRows.indexOf(row);
if (activeIndex > -1) {
@@ -2398,23 +2431,28 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.setActiveRows(this.activeRows);
- this.setDisplayRows(this.displayRows);
+ this.displayRowIterator(function (rows) {
+
+ var displayIndex = rows.indexOf(row);
+
+ if (displayIndex > -1) {
+
+ rows.splice(displayIndex, 1);
+ }
+ });
this.table.options.rowDeleted(row.getComponent());
this.table.options.dataEdited(this.getData());
- if (this.table.options.pagination && this.table.extExists("page")) {
+ if (this.table.options.groupBy && this.table.extExists("groupRows")) {
- this.refreshActiveData();
+ this.table.extensions.groupRows.updateGroupRows(true);
} else {
- if (this.table.options.groupBy && this.table.extExists("groupRows")) {
-
- this.table.extensions.groupRows.updateGroupRows(true);
- } else {
+ if (this.table.options.pagination && this.table.extExists("page")) {
- this.reRenderInPosition();
+ this.refreshActiveData("page");
}
}
};
@@ -2472,7 +2510,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.table.extExists("columnCalcs")) {
- this.table.extensions.columnCalcs.recalc(this.table.rowManager.displayRows);
+ this.table.extensions.columnCalcs.recalc(this.table.rowManager.activeRows);
}
return rows;
@@ -2545,13 +2583,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (index) {
var allIndex = this.rows.indexOf(index),
- activeIndex = this.activeRows.indexOf(index),
- displayIndex = this.displayRows.indexOf(index);
+ activeIndex = this.activeRows.indexOf(index);
- if (displayIndex > -1) {
+ this.displayRowIterator(function (rows) {
- this.displayRows.splice(top ? displayIndex : displayIndex + 1, 0, row);
- }
+ displayIndex = rows.indexOf(index);
+
+ if (displayIndex > -1) {
+
+ rows.splice(top ? displayIndex : displayIndex + 1, 0, row);
+ }
+ });
if (activeIndex > -1) {
@@ -2566,14 +2608,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (top) {
- this.displayRows.unshift(row);
+ this.displayRowIterator(function (rows) {
+
+ rows.unshift(row);
+ });
this.activeRows.unshift(row);
this.rows.unshift(row);
} else {
- this.displayRows.push(row);
+ this.displayRowIterator(function (rows) {
+
+ rows.push(row);
+ });
this.activeRows.push(row);
@@ -2581,8 +2629,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
}
- this.setDisplayRows(this.displayRows);
-
this.setActiveRows(this.activeRows);
this.table.options.rowAdded(row.getComponent());
@@ -2611,11 +2657,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.moveRowActual = function (from, to, after) {
+ var self = this;
+
this._moveRowInArray(this.rows, from, to, after);
this._moveRowInArray(this.activeRows, from, to, after);
- this._moveRowInArray(this.displayRows, from, to, after);
+ this.displayRowIterator(function (rows) {
+
+ self._moveRowInArray(rows, from, to, after);
+ });
if (this.table.options.groupBy && this.table.extExists("groupRows")) {
@@ -2669,7 +2720,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
//restyle rows
- if (rows === this.displayRows) {
+ if (rows === this.getDisplayRows()) {
start = fromIndex < toIndex ? fromIndex : toIndex;
@@ -2698,7 +2749,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.getDisplayRowIndex = function (row) {
- return this.findRowIndex(row, this.displayRows);
+ return this.findRowIndex(row, this.getDisplayRows());
};
RowManager.prototype.nextDisplayRow = function (row) {
@@ -2708,7 +2759,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (index !== false && index < this.displayRowsCount - 1) {
- nextRow = this.displayRows[index + 1];
+ nextRow = this.getDisplayRows()[index + 1];
}
return nextRow;
@@ -2721,7 +2772,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (index) {
- prevRow = this.displayRows[index - 1];
+ prevRow = this.getDisplayRows()[index - 1];
}
return prevRow;
@@ -2764,20 +2815,22 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.getHtml = function (active) {
var data = this.getData(active),
- columns = this.table.columnManager.getComponents(),
+ columns = [],
header = "",
body = "",
table = "";
//build header row
- columns.forEach(function (column) {
+ this.table.columnManager.getComponents().forEach(function (column) {
var def = column.getDefinition();
if (column.getVisibility() && !def.hideInHtml) {
header += '
' + (def.title || "") + ' | ';
+
+ columns.push(column);
}
});
@@ -2891,7 +2944,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
} else {
- this.refreshActiveData();
+ this.refreshActiveData("filter");
}
this.scrollHorizontal(left);
@@ -2920,7 +2973,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
} else {
- this.refreshActiveData();
+ this.refreshActiveData("sort");
}
this.scrollHorizontal(left);
@@ -2931,93 +2984,189 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.scrollLeft = left;
this.element.scrollLeft(left);
+
+ if (this.table.options.groupBy) {
+
+ this.table.extensions.groupRows.scrollHeaders(left);
+ }
+
+ if (this.table.extExists("columnCalcs")) {
+
+ this.table.extensions.columnCalcs.scrollHorizontal(left);
+ }
};
//set active data set
- RowManager.prototype.refreshActiveData = function (dataChanged) {
+ RowManager.prototype.refreshActiveData = function (stage, skipStage, renderInPosition) {
var self = this,
- table = this.table;
+ table = this.table,
+ displayIndex;
+
+ if (!stage) {
+
+ stage = "all";
+ }
if (table.options.selectable && !table.options.selectablePersistence && table.extExists("selectRow")) {
table.extensions.selectRow.deselectRows();
}
- //filter data
+ //cascade through data refresh stages
- if (table.extExists("filter")) {
+ switch (stage) {
- if (table.extensions.filter.hasChanged() || dataChanged) {
+ case "all":
- self.setActiveRows(table.extensions.filter.filter(self.rows));
+ case "filter":
- dataChanged = true;
- }
- } else {
+ if (!skipStage) {
- self.setActiveRows(self.rows.slice(0));
- }
+ if (table.extExists("filter")) {
- //sort data
+ self.setActiveRows(table.extensions.filter.filter(self.rows));
+ } else {
- if (table.extExists("sort")) {
+ self.setActiveRows(self.rows.slice(0));
+ }
+ } else {
- if (table.extensions.sort.hasChanged() || dataChanged) {
+ skipStage = false;
+ }
- table.extensions.sort.sort();
+ case "sort":
- dataChanged = true;
- }
- }
+ if (!skipStage) {
- //group data
+ if (table.extExists("sort")) {
- if (table.options.groupBy && table.extExists("groupRows")) {
+ table.extensions.sort.sort();
+ }
+ } else {
- self.setDisplayRows(table.extensions.groupRows.getRows(this.activeRows, dataChanged));
+ skipStage = false;
+ }
- if (table.options.pagination) {
+ //generic stage to allow for pipeline trigger after the data manipulation stage
- console.warn("Invalid Setup Combination - Pagination and Row Grouping cannot be enabled at the same time");
- }
- } else {
+ case "display":
- //paginate data
+ this.resetDisplayRows();
- if (table.options.pagination && table.extExists("page")) {
+ case "freeze":
- if (table.extensions.page.getMode() == "local") {
+ if (!skipStage) {
- if (dataChanged) {
+ if (this.table.extExists("frozenRows")) {
- table.extensions.page.reset();
+ if (table.extensions.frozenRows.isFrozen()) {
+
+ if (!table.extensions.frozenRows.getDisplayIndex()) {
+
+ table.extensions.frozenRows.setDisplayIndex(this.getNextDisplayIndex());
+ }
+
+ displayIndex = table.extensions.frozenRows.getDisplayIndex();
+
+ displayIndex = self.setDisplayRows(table.extensions.frozenRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);
+
+ if (displayIndex !== true) {
+
+ table.extensions.frozenRows.setDisplayIndex(displayIndex);
+ }
+ }
}
+ } else {
- table.extensions.page.setMaxRows(this.activeRows.length);
+ skipStage = false;
}
- self.setDisplayRows(table.extensions.page.getRows(this.activeRows));
- } else {
+ case "group":
+
+ if (!skipStage) {
+
+ if (table.options.groupBy && table.extExists("groupRows")) {
+
+ if (!table.extensions.groupRows.getDisplayIndex()) {
+
+ table.extensions.groupRows.setDisplayIndex(this.getNextDisplayIndex());
+ }
+
+ displayIndex = table.extensions.groupRows.getDisplayIndex();
+
+ displayIndex = self.setDisplayRows(table.extensions.groupRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);
+
+ if (displayIndex !== true) {
+
+ table.extensions.groupRows.setDisplayIndex(displayIndex);
+ }
+ }
+ } else {
+
+ skipStage = false;
+ }
+
+ if (table.options.pagination && table.extExists("page")) {
+
+ if (table.extensions.page.getMode() == "local") {
+
+ table.extensions.page.reset();
+ }
+ }
+
+ case "page":
+
+ if (!skipStage) {
+
+ if (table.options.pagination && table.extExists("page")) {
+
+ if (!table.extensions.page.getDisplayIndex()) {
+
+ table.extensions.page.setDisplayIndex(this.getNextDisplayIndex());
+ }
+
+ displayIndex = table.extensions.page.getDisplayIndex();
+
+ if (table.extensions.page.getMode() == "local") {
+
+ table.extensions.page.setMaxRows(this.getDisplayRows(displayIndex - 1).length);
+ }
+
+ displayIndex = self.setDisplayRows(table.extensions.page.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);
+
+ if (displayIndex !== true) {
+
+ table.extensions.page.setDisplayIndex(displayIndex);
+ }
+ }
+ } else {
+
+ skipStage = false;
+ }
- self.setDisplayRows(self.activeRows.slice(0));
- }
}
if (self.element.is(":visible")) {
- self.renderTable();
+ if (renderInPosition) {
- if (table.options.layoutColumnsOnNewData) {
+ self.reRenderInPosition();
+ } else {
+
+ self.renderTable();
- self.table.columnManager.redraw(true);
+ if (table.options.layoutColumnsOnNewData) {
+
+ self.table.columnManager.redraw(true);
+ }
}
}
if (table.extExists("columnCalcs")) {
- table.extensions.columnCalcs.recalc(this.displayRows);
+ table.extensions.columnCalcs.recalc(this.activeRows);
}
};
@@ -3028,16 +3177,81 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.activeRowsCount = this.activeRows.length;
};
- RowManager.prototype.setDisplayRows = function (displayRows) {
+ //reset display rows array
+
+ RowManager.prototype.resetDisplayRows = function () {
+
+ this.displayRows = [];
+
+ this.displayRows.push(this.activeRows.slice(0));
- this.displayRows = displayRows;
+ this.displayRowsCount = this.displayRows[0].length;
if (this.table.extExists("frozenRows")) {
- this.table.extensions.frozenRows.filterFrozenRows();
+ this.table.extensions.frozenRows.setDisplayIndex(0);
+ }
+
+ if (this.table.options.groupBy && this.table.extExists("groupRows")) {
+
+ this.table.extensions.groupRows.setDisplayIndex(0);
+ }
+
+ if (this.table.options.pagination && this.table.extExists("page")) {
+
+ this.table.extensions.page.setDisplayIndex(0);
+ }
+ };
+
+ RowManager.prototype.getNextDisplayIndex = function () {
+
+ return this.displayRows.length;
+ };
+
+ //set display row pipeline data
+
+ RowManager.prototype.setDisplayRows = function (displayRows, index) {
+
+ var output = true;
+
+ if (index && typeof this.displayRows[index] != "undefined") {
+
+ this.displayRows[index] = displayRows;
+
+ output = true;
+ } else {
+
+ this.displayRows.push(displayRows);
+
+ output = index = this.displayRows.length - 1;
+ }
+
+ if (index == this.displayRows.length - 1) {
+
+ this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
+ }
+
+ return output;
+ };
+
+ RowManager.prototype.getDisplayRows = function (index) {
+
+ if (typeof index == "undefined") {
+
+ return this.displayRows.length ? this.displayRows[this.displayRows.length - 1] : [];
+ } else {
+
+ return this.displayRows[index] || [];
}
+ };
- this.displayRowsCount = this.displayRows.length;
+ //repeat action accross display rows
+
+ RowManager.prototype.displayRowIterator = function (callback) {
+
+ this.displayRows.forEach(callback(rows));
+
+ this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
};
//return only actual rows (not group headers etc)
@@ -3062,22 +3276,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var topOffset = false;
+ var left = this.scrollLeft;
+
+ var rows = this.getDisplayRows();
+
for (var i = this.vDomTop; i <= this.vDomBottom; i++) {
- if (this.displayRows[i]) {
+ if (rows[i]) {
- var diff = scrollTop - this.displayRows[i].getElement().position().top;
+ var diff = scrollTop - rows[i].getElement().position().top;
if (topOffset === false || Math.abs(diff) < topOffset) {
topOffset = diff;
topRow = i;
+ } else {
+
+ break;
}
}
}
- this._virtualRenderFill(topRow === false ? this.displayRows.length - 1 : topRow, true, topOffset || 0);
+ this._virtualRenderFill(topRow === false ? this.displayRowsCount - 1 : topRow, true, topOffset || 0);
+
+ this.scrollHorizontal(left);
} else {
this.renderTable();
@@ -3086,7 +3309,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype.setRenderMode = function () {
- if ((this.table.element.innerHeight() || this.table.options.height) && this.table.options.virtualDom && !this.table.options.pagination) {
+ if ((this.table.element.innerHeight() || this.table.options.height) && this.table.options.virtualDom) {
this.renderMode = "virtual";
} else {
@@ -3164,7 +3387,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (self.displayRowsCount) {
- self.displayRows.forEach(function (row, index) {
+ self.getDisplayRows().forEach(function (row, index) {
self.styleRow(row, index);
@@ -3254,7 +3477,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
topPad = 0,
rowsHeight = 0,
topPadHeight = 0,
- i = 0;
+ i = 0,
+ rows = self.getDisplayRows();
position = position || 0;
@@ -3297,7 +3521,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
while ((rowsHeight <= self.height + self.vDomWindowBuffer || i < self.vDomWindowMinTotalRows) && self.vDomBottom < self.displayRowsCount - 1) {
var index = self.vDomBottom + 1,
- row = self.displayRows[index];
+ row = rows[index];
self.styleRow(row, index);
@@ -3447,12 +3671,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- var table = this.tableElement;
+ var table = this.tableElement,
+ rows = this.getDisplayRows();
if (this.vDomTop) {
var index = this.vDomTop - 1,
- topRow = this.displayRows[index],
+ topRow = rows[index],
topRowHeight = topRow.getHeight() || this.vDomRowHeight;
//hide top row if needed
@@ -3496,7 +3721,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
topDiff = -(this.scrollTop - this.vDomScrollPosTop);
- if (i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (this.displayRows[this.vDomTop - 1].getHeight() || this.vDomRowHeight)) {
+ if (i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (rows[this.vDomTop - 1].getHeight() || this.vDomRowHeight)) {
this._addTopRow(topDiff, i + 1);
} else {
@@ -3509,7 +3734,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype._removeTopRow = function (topDiff) {
var table = this.tableElement,
- topRow = this.displayRows[this.vDomTop],
+ topRow = this.getDisplayRows()[this.vDomTop],
topRowHeight = topRow.getHeight() || this.vDomRowHeight;
if (topDiff >= topRowHeight) {
@@ -3534,12 +3759,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- var table = this.tableElement;
+ var table = this.tableElement,
+ rows = this.getDisplayRows();
if (this.vDomBottom < this.displayRowsCount - 1) {
var index = this.vDomBottom + 1,
- bottomRow = this.displayRows[index],
+ bottomRow = rows[index],
bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
//hide bottom row if needed
@@ -3578,7 +3804,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
bottomDiff = this.scrollTop - this.vDomScrollPosBottom;
- if (i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount - 1 && bottomDiff >= (this.displayRows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)) {
+ if (i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount - 1 && bottomDiff >= (rows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)) {
this._addBottomRow(bottomDiff, i + 1);
} else {
@@ -3591,7 +3817,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
RowManager.prototype._removeBottomRow = function (bottomDiff) {
var table = this.tableElement,
- bottomRow = this.displayRows[this.vDomBottom],
+ bottomRow = this.getDisplayRows()[this.vDomBottom],
bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
if (bottomDiff >= bottomRowHeight) {
@@ -3638,7 +3864,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var self = this;
- self.displayRows.forEach(function (row) {
+ self.activeRows.forEach(function (row) {
row.normalizeHeight();
});
@@ -4378,7 +4604,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.extensions.columnCalcs.recalcRowGroup(this);
} else {
- this.table.extensions.columnCalcs.recalc(this.table.rowManager.displayRows);
+ this.table.extensions.columnCalcs.recalc(this.table.rowManager.activeRows);
}
}
};
@@ -4605,6 +4831,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
});
}
+ if (this.table.options.tooltipGenerationMode === "hover") {
+
+ //update tooltip on mouse enter
+
+ self.element.on("mouseenter", function (e) {
+
+ self._generateTooltip();
+ });
+ }
+
if (cellEvents.cellTap) {
tap = false;
@@ -4727,6 +4963,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
} else if (typeof tooltip == "function") {
tooltip = tooltip(self.getComponent());
+
+ if (tooltip === false) {
+
+ tooltip = "";
+ }
}
self.element[0].setAttribute("title", tooltip);
@@ -4789,7 +5030,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.extensions.columnCalcs.recalcRowGroup(this.row);
} else {
- this.table.extensions.columnCalcs.recalc(this.table.rowManager.displayRows);
+ this.table.extensions.columnCalcs.recalc(this.table.rowManager.activeRows);
}
}
}
@@ -4903,7 +5144,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.table.extExists("edit", true)) {
- return this.table.extensions.edit.edit(this, false, force);
+ return this.table.extensions.edit.editCell(this, false, force);
}
};
@@ -5201,6 +5442,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
tooltipsHeader: false, //Tool tip for headers
+ tooltipGenerationMode: "load", //when to generate tooltips
+
initialSort: false, //initial sorting criteria
@@ -5216,6 +5459,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
downloadDataMutator: false, //function to manipulate table data before it is downloaded
+ downloadReady: function downloadReady(data, blob) {
+ return blob;
+ }, //function to manipulate download data
+
+ downloadComplete: false, //function to manipulate download data
+
addRowPos: "bottom", //position to insert blank rows, top|bottom
@@ -5264,6 +5513,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
paginationSize: false, //set number of rows to a page
+ paginationButtonCount: 5, // set count of page button
+
paginationElement: false, //element to hold pagination numbers
paginationDataSent: {}, //pagination data sent to the server
@@ -5505,16 +5756,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self._buildElement();
- //give the browser a chance to fully render the table then load first data set if present
-
- // setTimeout(function(){
-
-
//load initial data set
this._loadInitialData();
-
- // },20)
}
},
@@ -5523,9 +5767,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
_clearObjectPointers: function _clearObjectPointers() {
- this.options.columns = this.options.columns.splice(0);
+ this.options.columns = this.options.columns.slice(0);
- this.options.data = this.options.data.splice(0);
+ this.options.data = this.options.data.slice(0);
},
//build tabulator element
@@ -5672,6 +5916,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
ext.resizeTable.initialize();
}
+ if (this.extExists("clipboard")) {
+
+ ext.clipboard.initialize();
+ }
+
options.tableBuilt();
},
@@ -5683,8 +5932,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.extensions.page.reset(true);
- self.extensions.page.setPage(1);
-
if (self.options.pagination == "local") {
if (self.options.data.length) {
@@ -5703,6 +5950,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.rowManager.setData(self.options.data);
}
}
+ } else {
+
+ self.extensions.page.setPage(1);
}
} else {
@@ -5738,6 +5988,33 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var element = this.element;
+ //clear row data
+
+ this.rowManager.rows.forEach(function (row) {
+
+ row.wipe();
+ });
+
+ this.rowManager.rows = [];
+
+ this.rowManager.activeRows = [];
+
+ this.rowManager.displayRows = [];
+
+ //clear event bindings
+
+ if (this.options.autoResize && this.extExists("resizeTable")) {
+
+ this.extensions.resizeTable.clearBindings();
+ }
+
+ if (this.extExists("keybindings")) {
+
+ this.extensions.keybindings.clearBindings();
+ }
+
+ //clear DOM
+
element.empty();
element.removeClass("tabulator");
@@ -6034,7 +6311,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.extExists("columnCalcs")) {
- this.extensions.columnCalcs.recalc(this.rowManager.displayRows);
+ this.extensions.columnCalcs.recalc(this.rowManager.activeRows);
}
return row.getComponent();
@@ -6062,7 +6339,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.extExists("columnCalcs")) {
- this.extensions.columnCalcs.recalc(this.rowManager.displayRows);
+ this.extensions.columnCalcs.recalc(this.rowManager.activeRows);
}
}
@@ -6132,6 +6409,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
},
+ //copy table data to clipboard
+
+ copyToClipboard: function copyToClipboard(mode, showHeaders) {
+
+ if (this.extExists("clipboard", true)) {
+
+ this.extensions.clipboard.copy(mode, showHeaders);
+ }
+ },
+
/////////////// Column Functions ///////////////
@@ -6177,6 +6464,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (column) {
column.show();
+
+ if (this.options.responsiveLayout && this.extExists("responsiveLayout", true)) {
+
+ this.extensions.responsiveLayout.update();
+ }
} else {
console.warn("Column Show Error - No matching column found:", field);
@@ -6192,6 +6484,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (column) {
column.hide();
+
+ if (this.options.responsiveLayout && this.extExists("responsiveLayout", true)) {
+
+ this.extensions.responsiveLayout.update();
+ }
} else {
console.warn("Column Hide Error - No matching column found:", field);
@@ -6608,7 +6905,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.extensions.groupRows.initialize();
- this.rowManager.refreshActiveData();
+ this.rowManager.refreshActiveData("display");
} else {
return false;
@@ -6625,7 +6922,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.options.groupBy) {
- this.rowManager.refreshActiveData();
+ this.rowManager.refreshActiveData("group");
} else {
console.warn("Grouping Update - cant refresh view, no groups have been set");
@@ -6646,7 +6943,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (this.options.groupBy) {
- this.rowManager.refreshActiveData();
+ this.rowManager.refreshActiveData("group");
} else {
console.warn("Grouping Update - cant refresh view, no groups have been set");
@@ -7006,61 +7303,109 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var flexWidth = 0; //total width available to flexible columns
+ var flexGrowUnits = 0; //total number of widthGrow blocks accross all columns
+
+
var flexColWidth = 0; //desired width of flexible columns
var flexColumns = []; //array of flexible width columns
+ var fixedShrinkColumns = []; //array of fixed width columns that can shrink
+
+
+ var flexShrinkUnits = 0; //total number of widthShrink blocks accross all columns
+
+
+ var overflowWidth = 0; //horizontal overflow width
+
+
var gapFill = 0; //number of pixels to be added to final column to close and half pixel gaps
+ function calcWidth(width) {
+
+ var colWidth;
+
+ if (typeof width == "string") {
+
+ if (width.indexOf("%") > -1) {
+
+ colWidth = totalWidth / 100 * parseInt(width);
+ } else {
+
+ colWidth = parseInt(width);
+ }
+ } else {
+
+ colWidth = width;
+ }
+
+ return colWidth;
+ }
+
//ensure columns resize to take up the correct amount of space
- function scaleColumns(columns, freeSpace, colWidth) {
+ function scaleColumns(columns, freeSpace, colWidth, shrinkCols) {
var oversizeCols = [],
oversizeSpace = 0,
remainingSpace = 0,
nextColWidth = 0,
gap = 0,
+ changeUnits = 0,
undersizeCols = [];
- columns.forEach(function (column, i) {
+ function calcGrow(col) {
+
+ return colWidth * (col.column.definition.widthGrow || 1);
+ }
+
+ function calcShrink(col) {
- if (column.minWidth >= colWidth) {
+ return calcWidth(col.width) - colWidth * (col.column.definition.widthShrink || 0);
+ }
+
+ columns.forEach(function (col, i) {
+
+ var width = shrinkCols ? calcShrink(col) : calcGrow(col);
+
+ if (col.column.minWidth >= width) {
- oversizeCols.push(column);
+ oversizeCols.push(col);
} else {
- undersizeCols.push(column);
+ undersizeCols.push(col);
+
+ changeUnits += shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1;
}
});
if (oversizeCols.length) {
- oversizeCols.forEach(function (column) {
+ oversizeCols.forEach(function (col) {
- oversizeSpace += column.minWidth;
+ oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;
- column.setWidth(column.minWidth);
+ col.width = col.column.minWidth;
});
remainingSpace = freeSpace - oversizeSpace;
- nextColWidth = undersizeCols.length ? Math.floor(remainingSpace / undersizeCols.length) : remainingSpace;
+ nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace;
- gap = remainingSpace - nextColWidth * undersizeCols.length;
+ gap = remainingSpace - nextColWidth * changeUnits;
- gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth);
+ gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
} else {
- gap = undersizeCols.length ? freeSpace - Math.floor(freeSpace / undersizeCols.length) * undersizeCols.length : freeSpace;
+ gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace;
undersizeCols.forEach(function (column) {
- column.setWidth(colWidth);
+ column.width = shrinkCols ? calcShrink(column) : calcGrow(column);
});
}
@@ -7092,24 +7437,33 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (width) {
- if (typeof width == "string") {
+ colWidth = calcWidth(width);
- if (width.indexOf("%") > -1) {
+ fixedWidth += colWidth > minWidth ? colWidth : minWidth;
- colWidth = totalWidth / 100 * parseInt(width);
- } else {
+ if (column.definition.widthShrink) {
- colWidth = parseInt(width);
- }
- } else {
+ fixedShrinkColumns.push({
- colWidth = width;
- }
+ column: column,
- fixedWidth += colWidth > minWidth ? colWidth : minWidth;
+ width: colWidth > minWidth ? colWidth : minWidth
+
+ });
+
+ flexShrinkUnits += column.definition.widthShrink;
+ }
} else {
- flexColumns.push(column);
+ flexColumns.push({
+
+ column: column,
+
+ width: 0
+
+ });
+
+ flexGrowUnits += column.definition.widthGrow || 1;
}
}
});
@@ -7122,20 +7476,56 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
//calculate correct column size
- flexColWidth = Math.floor(flexWidth / flexColumns.length);
+ flexColWidth = Math.floor(flexWidth / flexGrowUnits);
//generate column widths
- var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth);
+ var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false);
//increase width of last column to account for rounding errors
- if (flexColumns.length) {
+ if (flexColumns.length && gapFill > 0) {
+
+ flexColumns[flexColumns.length - 1].width += +gapFill;
+ }
+
+ //caculate space for columns to be shrunk into
+
+
+ flexColumns.forEach(function (col) {
+
+ flexWidth -= col.width;
+ });
+
+ overflowWidth = Math.abs(gapFill) + flexWidth;
+
+ //shrink oversize columns if there is no available space
+
+
+ if (overflowWidth > 0 && flexShrinkUnits) {
+
+ gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true);
+ }
+
+ //decrease width of last column to account for rounding errors
+
+
+ if (fixedShrinkColumns.length) {
- flexColumns[flexColumns.length - 1].setWidth(flexColumns[flexColumns.length - 1].getWidth() + gapFill);
+ fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill;
}
+
+ flexColumns.forEach(function (col) {
+
+ col.column.setWidth(col.width);
+ });
+
+ fixedShrinkColumns.forEach(function (col) {
+
+ col.column.setWidth(col.width);
+ });
}
};
@@ -7493,7 +7883,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (typeof data[field] != "undefined") {
- column.setFieldValue(data, column.extensions.accessor.accessor(column.getFieldValue(data), data, column.extensions.accessor.params));
+ column.setFieldValue(data, column.extensions.accessor.accessor(column.getFieldValue(data), data, column.extensions.accessor.params, column.getComponent()));
}
}
});
@@ -7717,7 +8107,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.msgElement.append(this.loadingElement);
} else {
- this.msgElement.append(this.table.extensions.localize.getText("ajax.loading"));
+ this.msgElement.append(this.table.extensions.localize.getText("ajax|loading"));
}
this.table.element.append(this.loaderElement);
@@ -7735,7 +8125,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.msgElement.append(this.errorElement);
} else {
- this.msgElement.append(this.table.extensions.localize.getText("ajax.error"));
+ this.msgElement.append(this.table.extensions.localize.getText("ajax|error"));
}
this.table.element.append(this.loaderElement);
@@ -8356,6 +8746,183 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
Tabulator.registerExtension("columnCalcs", ColumnCalcs);
+ var Clipboard = function Clipboard(table) {
+
+ this.table = table;
+
+ this.mode = "table";
+
+ this.showHeaders = true;
+
+ this.blocked = true; //block copy actions not originating from this command
+
+
+ this.originalSelectionText = ""; //hold text from original selection if text is selected
+
+ };
+
+ Clipboard.prototype.initialize = function () {
+
+ var self = this;
+
+ this.table.element.on("copy", function (e) {
+
+ if (!self.blocked) {
+
+ e.preventDefault();
+
+ e.originalEvent.clipboardData.setData('text/plain', self.generateContent());
+
+ self.reset();
+ }
+ });
+ };
+
+ Clipboard.prototype.reset = function () {
+
+ this.blocked = false;
+
+ this.originalSelectionText = "";
+ };
+
+ Clipboard.prototype.copy = function (mode, showHeaders, internal) {
+
+ var range, sel;
+
+ this.blocked = false;
+
+ this.mode = mode || "table";
+
+ this.showHeaders = showHeaders === false ? false : true;
+
+ if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
+
+ range = document.createRange();
+
+ range.selectNodeContents(this.table.element[0]);
+
+ sel = window.getSelection();
+
+ if (sel.anchorNode && internal) {
+
+ this.mode = "userSelection";
+
+ this.originalSelectionText = sel.toString();
+ }
+
+ sel.removeAllRanges();
+
+ sel.addRange(range);
+ } else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {
+
+ textRange = document.body.createTextRange();
+
+ textRange.moveToElementText(this.table.element[0]);
+
+ textRange.select();
+ }
+
+ document.execCommand('copy');
+
+ if (sel) {
+
+ sel.removeAllRanges();
+ }
+ };
+
+ Clipboard.prototype.generateContent = function () {
+
+ var data = [],
+ headers = [],
+ columns = this.table.columnManager.columnsByIndex,
+ rows;
+
+ if (this.mode == "userSelection") {
+
+ return this.originalSelectionText;
+ }
+
+ if (this.showHeaders) {
+
+ columns.forEach(function (column) {
+
+ headers.push(column.definition.title);
+ });
+
+ data.push(headers);
+ }
+
+ switch (this.mode) {
+
+ case "selected":
+
+ if (this.table.extExists("selectRow", true)) {
+
+ rows = this.table.extensions.selectRow.getSelectedRows();
+ }
+
+ break;
+
+ case "table":
+
+ rows = this.table.rowManager.getComponents();
+
+ break;
+
+ case "active":
+
+ default:
+
+ rows = this.table.rowManager.getComponents(true);
+
+ }
+
+ rows.forEach(function (row) {
+
+ var rowArray = [],
+ rowData = row.getData();
+
+ columns.forEach(function (column) {
+
+ var value = column.getFieldValue(rowData);
+
+ if (typeof value == "undefined") {
+
+ value = "";
+ }
+
+ value = typeof value == "undefined" ? "" : value.toString();
+
+ if (value.match(/\r|\n/)) {
+
+ value = value.split('"').join('""');
+
+ value = '"' + value + '"';
+ }
+
+ rowArray.push(value);
+ });
+
+ data.push(rowArray);
+ });
+
+ return this.arrayToString(data);
+ };
+
+ Clipboard.prototype.arrayToString = function (data) {
+
+ var output = [];
+
+ data.forEach(function (row) {
+
+ output.push(row.join("\t"));
+ });
+
+ return output.join("\n");
+ };
+
+ Tabulator.registerExtension("clipboard", Clipboard);
+
var Download = function Download(table) {
this.table = table; //hold Tabulator object
@@ -8459,31 +9026,41 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
blob = new Blob([data], { type: mime }),
filename = filename || "Tabulator." + (typeof type === "function" ? "txt" : type);
- if (navigator.msSaveOrOpenBlob) {
+ blob = this.table.options.downloadReady(data, blob);
- navigator.msSaveOrOpenBlob(blob, filename);
- } else {
+ if (blob) {
+
+ if (navigator.msSaveOrOpenBlob) {
+
+ navigator.msSaveOrOpenBlob(blob, filename);
+ } else {
+
+ element.setAttribute('href', window.URL.createObjectURL(blob));
- element.setAttribute('href', window.URL.createObjectURL(blob));
+ //set file title
- //set file title
+ element.setAttribute('download', filename);
- element.setAttribute('download', filename);
+ //trigger download
- //trigger download
+ element.style.display = 'none';
- element.style.display = 'none';
+ document.body.appendChild(element);
- document.body.appendChild(element);
+ element.click();
- element.click();
+ //remove temporary link element
- //remove temporary link element
+ document.body.removeChild(element);
+ }
+
+ if (this.table.options.downloadComplete) {
- document.body.removeChild(element);
+ this.table.options.downloadComplete();
+ }
}
};
@@ -8721,6 +9298,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.mouseClick = false; //hold mousedown state to prevent click binding being overriden by editor opening
+
+ this.recursionBlock = false; //prevent focus recursion
+
+
+ this.invalidEdit = false;
};
//initialize column editor
@@ -8802,13 +9384,18 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var cell = this.currentCell;
- this.currentCell = false;
+ this.invalidEdit = false;
+
+ if (cell) {
- cell.getElement().removeClass("tabulator-validation-fail");
+ this.currentCell = false;
- cell.getElement().removeClass("tabulator-editing").empty();
+ cell.getElement().removeClass("tabulator-validation-fail");
- cell.row.getElement().removeClass("tabulator-row-editing");
+ cell.getElement().removeClass("tabulator-editing").empty();
+
+ cell.row.getElement().removeClass("tabulator-row-editing");
+ }
};
Edit.prototype.cancelEdit = function () {
@@ -8855,10 +9442,29 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.mouseClick = true;
});
- element.on("focus", function (e, force) {
+ element.on("focus", function (e) {
+
+ if (!self.recursionBlock) {
+
+ self.edit(cell, e, false);
+ }
+ });
+ };
+
+ Edit.prototype.focusCellNoEvent = function (cell) {
+
+ this.recursionBlock = true;
+
+ cell.getElement().focus();
+
+ this.recursionBlock = false;
+ };
+
+ Edit.prototype.editCell = function (cell, forceEdit) {
+
+ this.focusCellNoEvent(cell);
- self.edit(cell, e);
- });
+ this.edit(cell, false, forceEdit);
};
Edit.prototype.edit = function (cell, e, forceEdit) {
@@ -8870,12 +9476,18 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
cellEditor,
component;
- //if currently editing another cell trigger blur to trigger save and validate actions
+ //prevent editing if another cell is refusing to leave focus (eg. validation fail)
if (this.currentCell) {
- cell.getElement().focus();
+ if (!this.invalidEdit) {
+
+ this.cancelEdit();
+ } else {
+
+ return;
+ }
return;
}
@@ -8885,25 +9497,35 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
function success(value) {
- var valid = true;
+ if (self.currentCell === cell) {
- if (cell.column.extensions.validate && self.table.extExists("validate")) {
+ var valid = true;
- valid = self.table.extensions.validate.validate(cell.column.extensions.validate, cell.getComponent(), value);
- }
+ if (cell.column.extensions.validate && self.table.extExists("validate")) {
- if (valid === true) {
+ valid = self.table.extensions.validate.validate(cell.column.extensions.validate, cell.getComponent(), value);
+ }
- self.clearEditor();
+ if (valid === true) {
- cell.setValue(value, true);
- } else {
+ self.clearEditor();
- cell.getElement().addClass("tabulator-validation-fail");
+ cell.setValue(value, true);
+ } else {
+
+ self.invalidEdit = true;
+
+ cell.getElement().addClass("tabulator-validation-fail");
+
+ self.focusCellNoEvent(cell);
- rendered();
+ rendered();
+
+ self.table.options.validationFailed(cell.getComponent(), value, valid);
+ }
+ } else {
- self.table.options.validationFailed(cell.getComponent(), value, valid);
+ console.warn("Edit Success Error - cannot call success on a cell that is no longer being edited");
}
};
@@ -8912,7 +9534,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
function cancel() {
- self.cancelEdit();
+ if (self.currentCell === cell) {
+
+ self.cancelEdit();
+ } else {
+
+ console.warn("Edit Success Error - cannot call cancel on a cell that is no longer being edited");
+ }
};
function onRendered(callback) {
@@ -10039,7 +10667,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.table.extensions.localize.bind("headerFilters|columns|" + column.definition.field, function (value) {
- editorElement.attr("placeholder", typeof value !== "undefined" && value ? value : self.table.extensions.localize.getText("headerFilters.default"));
+ editorElement.attr("placeholder", typeof value !== "undefined" && value ? value : self.table.extensions.localize.getText("headerFilters|default"));
});
} else {
@@ -10987,6 +11615,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
element = cell.getElement(),
max = formatterParams && formatterParams.max ? formatterParams.max : 100,
min = formatterParams && formatterParams.min ? formatterParams.min : 0,
+ legendAlign = formatterParams && formatterParams.legendAlign ? formatterParams.legendAlign : "center",
percent,
percentValue,
color,
@@ -11130,7 +11759,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
element.attr("aria-label", percentValue);
- return "" + (legend ? "" + legend + "
" : "");
+ return "" + (legend ? "" + legend + "
" : "");
},
//background color
@@ -11409,6 +12038,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.topElement = $("");
this.rows = [];
+
+ this.displayIndex = 0; //index in display pipeline
+
};
FrozenRows.prototype.initialize = function () {
@@ -11418,23 +12050,41 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.columnManager.element.append(this.topElement);
};
- FrozenRows.prototype.filterFrozenRows = function () {
+ FrozenRows.prototype.setDisplayIndex = function (index) {
+
+ this.displayIndex = index;
+ };
+
+ FrozenRows.prototype.getDisplayIndex = function () {
+
+ return this.displayIndex;
+ };
+
+ FrozenRows.prototype.isFrozen = function () {
+
+ return !!this.rows.length;
+ };
+
+ //filter frozen rows out of display data
+
+
+ FrozenRows.prototype.getRows = function (rows) {
var self = this,
- frozen = [];
+ frozen = [],
+ output = rows.slice(0);
+
+ this.rows.forEach(function (row) {
- self.table.rowManager.displayRows.forEach(function (row, i) {
+ var index = output.indexOf(row);
- if (row.extensions.frozen == true) {
+ if (index > -1) {
- frozen.unshift(i);
+ output.splice(index, 1);
}
});
- frozen.forEach(function (index) {
-
- self.table.rowManager.displayRows.splice(index, 1);
- });
+ return output;
};
FrozenRows.prototype.freezeRow = function (row) {
@@ -11445,12 +12095,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.topElement.append(row.getElement());
- this.table.rowManager.adjustTableSize();
+ row.initialize();
+
+ row.normalizeHeight();
- this.table.rowManager.refreshActiveData();
+ this.table.rowManager.adjustTableSize();
this.rows.push(row);
+ this.table.rowManager.refreshActiveData("display");
+
this.styleRows();
} else {
@@ -11470,10 +12124,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.rowManager.adjustTableSize();
- this.table.rowManager.refreshActiveData();
-
this.rows.splice(index, 1);
+ this.table.rowManager.refreshActiveData("display");
+
if (this.rows.length) {
this.styleRows();
@@ -11994,7 +12648,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.visible = false;
- if (this.groupManager.table.rowManager.getRenderMode() == "classic") {
+ if (this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination) {
this.element.removeClass("tabulator-group-visible");
@@ -12016,7 +12670,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.visible = true;
- if (this.groupManager.table.rowManager.getRenderMode() == "classic") {
+ if (this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination) {
this.element.addClass("tabulator-group-visible");
@@ -12219,6 +12873,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.groups = {}; //hold row groups
+
+ this.displayIndex = 0; //index in display pipeline
+
};
//initialize group configuration
@@ -12344,6 +13001,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.initialized = true;
};
+ GroupRows.prototype.setDisplayIndex = function (index) {
+
+ this.displayIndex = index;
+ };
+
+ GroupRows.prototype.getDisplayIndex = function () {
+
+ return this.displayIndex;
+ };
+
//return appropriate rows with group headers
@@ -12452,9 +13119,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (force) {
- self.table.rowManager.setDisplayRows(output);
+ var displayIndex = self.table.rowManager.setDisplayRows(output, this.getDisplayIndex());
+
+ if (displayIndex !== true) {
- self.table.rowManager.reRenderInPosition();
+ this.setDisplayIndex(displayIndex);
+ }
+
+ self.table.rowManager.refreshActiveData("group", true, true);
}
return output;
@@ -12921,6 +13593,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.watchKeys = null;
this.pressedKeys = null;
+
+ this.keyupBinding = false;
+
+ this.keydownBinding = false;
};
Keybindings.prototype.initialize = function () {
@@ -13040,7 +13716,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var self = this;
- this.table.element.on("keydown", function (e) {
+ this.keyupBinding = function (e) {
var code = e.keyCode;
@@ -13055,9 +13731,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.checkBinding(e, binding);
});
}
- });
+ };
- this.table.element.on("keyup", function (e) {
+ this.keydownBinding = function (e) {
var code = e.keyCode;
@@ -13072,7 +13748,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.pressedKeys.splice(index, 1);
}
}
- });
+ };
+
+ this.table.element.on("keydown", this.keyupBinding);
+
+ this.table.element.on("keyup", this.keydownBinding);
+ };
+
+ Keybindings.prototype.clearBindings = function () {
+
+ if (this.keyupBinding) {
+
+ this.table.element.off("keydown", this.keyupBinding);
+ }
+
+ if (this.keydownBinding) {
+
+ this.table.element.off("keyup", this.keydownBinding);
+ }
};
Keybindings.prototype.checkBinding = function (e, binding) {
@@ -13126,7 +13819,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
undo: "ctrl + 90",
- redo: "ctrl + 89"
+ redo: "ctrl + 89",
+
+ copyToClipboard: "ctrl + 67"
};
@@ -13157,7 +13852,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
rowManager.element.scrollTop(newPos);
} else {
- rowManager.scrollToRow(rowManager.displayRows[0]);
+ rowManager.scrollToRow(rowManager.getDisplayRows()[0]);
}
}
@@ -13179,7 +13874,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
rowManager.element.scrollTop(newPos);
} else {
- rowManager.scrollToRow(rowManager.displayRows[rowManager.displayRows.length - 1]);
+ rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);
}
}
@@ -13194,7 +13889,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (rowManager.displayRowsCount) {
- rowManager.scrollToRow(rowManager.displayRows[0]);
+ rowManager.scrollToRow(rowManager.getDisplayRows()[0]);
}
this.table.element.focus();
@@ -13208,7 +13903,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (rowManager.displayRowsCount) {
- rowManager.scrollToRow(rowManager.displayRows[rowManager.displayRows.length - 1]);
+ rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);
}
this.table.element.focus();
@@ -13348,6 +14043,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table.extensions.history.redo();
}
}
+ },
+
+ copyToClipboard: function copyToClipboard(e) {
+
+ if (!this.table.extensions.edit.currentCell) {
+
+ if (this.table.extExists("clipboard", true)) {
+
+ this.table.extensions.clipboard.copy(!this.table.options.selectable || this.table.options.selectable == "highlight" ? "active" : "selected", true, true);
+ }
+ }
}
};
@@ -13740,7 +14446,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var self = this;
- self.table.rowManager.displayRows.forEach(function (row) {
+ self.table.rowManager.activeRows.forEach(function (row) {
if (row.type === "row" && row.extensions.moveRow.mousemove) {
@@ -13753,7 +14459,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var self = this;
- self.table.rowManager.displayRows.forEach(function (row) {
+ self.table.rowManager.activeRows.forEach(function (row) {
if (row.type === "row" && row.extensions.moveRow.mousemove) {
@@ -13931,7 +14637,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (column.extensions.mutate.type != "edit") {
- column.setFieldValue(data, column.extensions.mutate.mutator(column.getFieldValue(data), data, "data", column.extensions.mutate.params));
+ column.setFieldValue(data, column.extensions.mutate.mutator(column.getFieldValue(data), data, "data", column.extensions.mutate.params, column.getComponent()));
}
}
});
@@ -13977,9 +14683,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.page = 1;
+ this.count = 5;
+
this.max = 1;
this.paginator = false;
+
+ this.displayIndex = 0; //index in display pipeline
+
};
//setup pageination
@@ -14104,7 +14815,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.mode = self.table.options.pagination;
- self.size = self.table.options.paginationSize || Math.floor(self.table.rowManager.getElement().innerHeight() / 26);
+ self.size = self.table.options.paginationSize || Math.floor(self.table.rowManager.getElement().innerHeight() / 24);
+
+ self.count = self.table.options.paginationButtonCount;
+ };
+
+ Page.prototype.setDisplayIndex = function (index) {
+
+ this.displayIndex = index;
+ };
+
+ Page.prototype.getDisplayIndex = function () {
+
+ return this.displayIndex;
};
//calculate maximum page from number of rows
@@ -14189,9 +14912,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var self = this;
- var min = this.page < this.max - 2 ? this.page - 2 : this.page - (4 - (this.max - this.page));
+ var leftSize = Math.floor((this.count - 1) / 2);
- var max = this.page > 3 ? this.page + 2 : this.page + (5 - this.page);
+ var rightSize = Math.ceil((this.count - 1) / 2);
+
+ var min = this.max - this.page + leftSize + 1 < this.count ? this.max - this.count + 1 : Math.max(this.page - leftSize, 1);
+
+ var max = this.page <= rightSize ? Math.min(this.count, this.max) : Math.min(this.page + rightSize, this.max);
self.pagesElement.empty();
@@ -14347,11 +15074,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
Page.prototype.trigger = function () {
+ var left;
+
switch (this.mode) {
case "local":
- this.table.rowManager.refreshActiveData();
+ left = this.table.rowManager.scrollLeft;
+
+ this.table.rowManager.refreshActiveData("page");
+
+ this.table.rowManager.scrollHorizontal(left);
this.table.options.pageLoaded(this.getPage());
@@ -14463,14 +15196,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
Page.prototype._parseRemoteData = function (data) {
+ var left;
+
if (data[this.paginationDataReceivedNames.last_page]) {
if (data[this.paginationDataReceivedNames.data]) {
this.max = parseInt(data[this.paginationDataReceivedNames.last_page]);
+ left = this.table.rowManager.scrollLeft;
+
this.table.rowManager.setData(data[this.paginationDataReceivedNames.data]);
+ this.table.rowManager.scrollHorizontal(left);
+
this.table.options.pageLoaded(this.getPage());
} else {
@@ -15142,6 +15881,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.table = table; //hold Tabulator object
+
+ this.binding = false;
+
+ this.observer = false;
};
ResizeTable.prototype.initialize = function (row) {
@@ -15149,20 +15892,35 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var table = this.table,
observer;
- if (typeof ResizeObserver !== "undefined" && this.table.rowManager.getRenderMode() === "virtual") {
+ if (typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual") {
- observer = new ResizeObserver(function (entry) {
+ this.observer = new ResizeObserver(function (entry) {
table.redraw();
});
- observer.observe(table.element[0]);
+ this.observer.observe(table.element[0]);
} else {
- $(window).resize(function () {
+ this.binding = function () {
- $(".tabulator").tabulator("redraw");
- });
+ this.table.element.tabulator("redraw");
+ };
+
+ $(window).resize(this.binding);
+ }
+ };
+
+ ResizeTable.prototype.clearBindings = function (row) {
+
+ if (this.binding) {
+
+ $(window).off("resize", this.binding);
+ }
+
+ if (this.observer) {
+
+ this.observer.unobserve(this.table.element[0]);
}
};
@@ -15178,7 +15936,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.index = 0;
};
- //generate resposivle columns list
+ //generate resposive columns list
ResponsiveLayout.prototype.initialize = function () {
@@ -15188,15 +15946,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
//detemine level of responsivity for each column
- this.table.columnManager.columnsByIndex.forEach(function (column) {
+ this.table.columnManager.columnsByIndex.forEach(function (column, i) {
- var def = column.getDefinition();
+ if (column.extensions.responsive) {
- column.extensions.responsive = { order: typeof def.responsive === "undefined" ? 1 : def.responsive };
+ if (column.extensions.responsive.order && column.extensions.responsive.visible) {
- if (column.extensions.responsive.order) {
+ column.extensions.responsive.index = i;
- columns.push(column);
+ columns.push(column);
+ }
}
});
@@ -15207,12 +15966,42 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
columns = columns.sort(function (a, b) {
- return b.extensions.responsive.order - a.extensions.responsive.order;
+ var diff = b.extensions.responsive.order - a.extensions.responsive.order;
+
+ return diff || b.extensions.responsive.index - a.extensions.responsive.index;
});
this.columns = columns;
};
+ //define layout information
+
+
+ ResponsiveLayout.prototype.initializeColumn = function (column) {
+
+ var def = column.getDefinition();
+
+ column.extensions.responsive = { order: typeof def.responsive === "undefined" ? 1 : def.responsive, visible: def.visible === false ? false : true };
+ };
+
+ //update column visibility
+
+
+ ResponsiveLayout.prototype.updateColumnVisibility = function (column, visible) {
+
+ var index;
+
+ if (column.extensions.responsive) {
+
+ column.extensions.responsive.visible = visible;
+
+ this.initialize();
+ }
+ };
+
+ //redraw columns to fit space
+
+
ResponsiveLayout.prototype.update = function () {
var self = this,
@@ -15233,7 +16022,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (column) {
- column.hide();
+ column.hide(false, true);
self.index++;
} else {
@@ -15253,7 +16042,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (diff >= _column.getWidth()) {
- _column.show();
+ _column.show(false, true);
//set column width to prevent calculation loops on uninitialized columns
@@ -15660,7 +16449,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
- column.extensions.sort = { sorter: sorter, dir: "none", params: column.definition.sorterParams || {} };
+ column.extensions.sort = {
+
+ sorter: sorter, dir: "none",
+
+ params: column.definition.sorterParams || {},
+
+ startingDir: column.definition.headerSortStartingDir || "asc"
+
+ };
if (column.definition.headerSort !== false) {
@@ -15682,7 +16479,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (column.extensions.sort) {
- dir = column.extensions.sort.dir == "asc" ? "desc" : "asc";
+ dir = column.extensions.sort.dir == "asc" ? "desc" : column.extensions.sort.dir == "desc" ? "asc" : column.extensions.sort.startingDir;
if (e.shiftKey || e.ctrlKey) {
@@ -16001,6 +16798,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
number: function number(a, b, aRow, bRow, column, dir, params) {
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
var a = parseFloat(String(a).replace(",", ""));
var b = parseFloat(String(b).replace(",", ""));
@@ -16010,13 +16811,27 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (isNaN(a)) {
- return isNaN(b) ? 0 : -1;
+ emptyAlign = isNaN(b) ? 0 : -1;
} else if (isNaN(b)) {
- return 1;
+ emptyAlign = 1;
+ } else {
+
+ //compare valid values
+
+
+ return a - b;
+ }
+
+ //fix empty values in position
+
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
}
- return a - b;
+ return emptyAlign;
},
//sort strings
@@ -16024,28 +16839,57 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
string: function string(a, b, aRow, bRow, column, dir, params) {
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
var locale;
- switch (_typeof(params.locale)) {
+ //handle empty values
- case "boolean":
- if (params.locale) {
+ if (!a) {
- local = this.table.extensions.localize.getLocale();
- }
+ emptyAlign = !b ? 0 : -1;
+ } else if (!b) {
- break;
+ emptyAlign = 1;
+ } else {
- case "string":
+ //compare valid values
- locale = params.locale;
- break;
+ switch (_typeof(params.locale)) {
+
+ case "boolean":
+
+ if (params.locale) {
+
+ locale = this.table.extensions.localize.getLocale();
+ }
+
+ break;
+
+ case "string":
+
+ locale = params.locale;
+
+ break;
+
+ }
+ return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);
}
- return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);
+ //fix empty values in position
+
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
+ }
+
+ return emptyAlign;
},
//sort date
@@ -16057,6 +16901,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var format = params.format || "DD/MM/YYYY";
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
if (typeof moment != "undefined") {
a = moment(a, format);
@@ -16065,19 +16913,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (!a.isValid()) {
- a = -1000000000000000;
+ emptyAlign = !b.isValid() ? 0 : -1;
+ } else if (!b.isValid()) {
+
+ emptyAlign = 1;
+ } else {
+
+ //compare valid values
+
+
+ return a - b;
}
- if (!b.isValid()) {
+ //fix empty values in position
- b = -1000000000000000;
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
}
+
+ return emptyAlign;
} else {
console.error("Sort Error - 'date' sorter is dependant on moment.js");
}
-
- return a - b;
},
//sort hh:mm formatted times
@@ -16089,6 +16949,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var format = params.format || "hh:mm";
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
if (typeof moment != "undefined") {
a = moment(a, format);
@@ -16097,19 +16961,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (!a.isValid()) {
- a = -1000000000000000;
+ emptyAlign = !b.isValid() ? 0 : -1;
+ } else if (!b.isValid()) {
+
+ emptyAlign = 1;
+ } else {
+
+ //compare valid values
+
+
+ return a - b;
}
- if (!b.isValid()) {
+ //fix empty values in position
+
- b = -1000000000000000;
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
}
+
+ return emptyAlign;
} else {
console.error("Sort Error - 'date' sorter is dependant on moment.js");
}
-
- return a - b;
},
//sort datetime
@@ -16121,6 +16997,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var format = params.format || "DD/MM/YYYY hh:mm:ss";
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
if (typeof moment != "undefined") {
a = moment(a, format);
@@ -16129,19 +17009,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (!a.isValid()) {
- a = -1000000000000000;
+ emptyAlign = !b.isValid() ? 0 : -1;
+ } else if (!b.isValid()) {
+
+ emptyAlign = 1;
+ } else {
+
+ //compare valid values
+
+
+ return a - b;
}
- if (!b.isValid()) {
+ //fix empty values in position
+
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
- b = -1000000000000000;
+ emptyAlign *= -1;
}
+
+ return emptyAlign;
} else {
- console.error("Sort Error - 'datetime' sorter is dependant on moment.js");
+ console.error("Sort Error - 'date' sorter is dependant on moment.js");
}
-
- return a - b;
},
//sort booleans
@@ -16167,16 +17059,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
var type = params.type || "length";
- //handle non array values
-
-
- if (!Array.isArray(a)) {
-
- return !Array.isArray(b) ? 0 : -1;
- } else if (!Array.isArray(b)) {
+ var alignEmptyValues = params.alignEmptyValues;
- return 1;
- }
+ var emptyAlign = 0;
function calc(value) {
@@ -16221,11 +17106,36 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
}
- el1 = a ? calc(a) : 0;
+ //handle non array values
- el2 = b ? calc(b) : 0;
- return el1 - el2;
+ if (!Array.isArray(a)) {
+
+ alignEmptyValues = !Array.isArray(b) ? 0 : -1;
+ } else if (!Array.isArray(b)) {
+
+ alignEmptyValues = 1;
+ } else {
+
+ //compare valid values
+
+
+ el1 = a ? calc(a) : 0;
+
+ el2 = b ? calc(b) : 0;
+
+ return el1 - el2;
+ }
+
+ //fix empty values in position
+
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
+ }
+
+ return emptyAlign;
},
//sort if element contains any data
@@ -16254,42 +17164,68 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
rx = /(\d+)|(\D+)/g,
rd = /\d/;
- if (isFinite(as) && isFinite(bs)) return as - bs;
+ var alignEmptyValues = params.alignEmptyValues;
+
+ var emptyAlign = 0;
+
+ //handle empty values
+
+
+ if (!as && as !== 0) {
+
+ emptyAlign = !bs && bs !== 0 ? 0 : -1;
+ } else if (!bs && bs !== 0) {
+
+ emptyAlign = 1;
+ } else {
+
+ if (isFinite(as) && isFinite(bs)) return as - bs;
- a = String(as).toLowerCase();
+ a = String(as).toLowerCase();
- b = String(bs).toLowerCase();
+ b = String(bs).toLowerCase();
- if (a === b) return 0;
+ if (a === b) return 0;
- if (!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;
+ if (!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;
- a = a.match(rx);
+ a = a.match(rx);
- b = b.match(rx);
+ b = b.match(rx);
- L = a.length > b.length ? b.length : a.length;
+ L = a.length > b.length ? b.length : a.length;
- while (i < L) {
+ while (i < L) {
- a1 = a[i];
+ a1 = a[i];
- b1 = b[i++];
+ b1 = b[i++];
- if (a1 !== b1) {
+ if (a1 !== b1) {
- if (isFinite(a1) && isFinite(b1)) {
+ if (isFinite(a1) && isFinite(b1)) {
- if (a1.charAt(0) === "0") a1 = "." + a1;
+ if (a1.charAt(0) === "0") a1 = "." + a1;
- if (b1.charAt(0) === "0") b1 = "." + b1;
+ if (b1.charAt(0) === "0") b1 = "." + b1;
- return a1 - b1;
- } else return a1 > b1 ? 1 : -1;
+ return a1 - b1;
+ } else return a1 > b1 ? 1 : -1;
+ }
}
+
+ return a.length > b.length;
+ }
+
+ //fix empty values in position
+
+
+ if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
+
+ emptyAlign *= -1;
}
- return a.length > b.length;
+ return emptyAlign;
}
};
diff --git a/lib/tabulator.min.css b/lib/tabulator.min.css
index 8055a75..4aeb286 100644
--- a/lib/tabulator.min.css
+++ b/lib/tabulator.min.css
@@ -1,3 +1,3 @@
-/* Tabulator v3.4.4 (c) Oliver Folkerd */
+/* Tabulator v3.5.0 (c) Oliver Folkerd */
.tabulator{position:relative;border:1px solid #999;background-color:#888;font-size:14px;text-align:left;overflow:hidden;transform:translatez(0)}.tabulator[tabulator-layout=fitDataFill] .tabulator-tableHolder .tabulator-table{min-width:100%}.tabulator.tabulator-block-select{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.tabulator .tabulator-header{position:relative;box-sizing:border-box;width:100%;border-bottom:1px solid #999;background-color:#e6e6e6;color:#555;font-weight:700;white-space:nowrap;overflow:hidden;-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none}.tabulator .tabulator-header .tabulator-col{display:inline-block;position:relative;box-sizing:border-box;border-right:1px solid #aaa;background:#e6e6e6;text-align:left;vertical-align:bottom;overflow:hidden}.tabulator .tabulator-header .tabulator-col.tabulator-moving{position:absolute;border:1px solid #999;background:#cdcdcd;pointer-events:none}.tabulator .tabulator-header .tabulator-col .tabulator-col-content{position:relative;padding:4px}.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title{box-sizing:border-box;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title .tabulator-title-editor{box-sizing:border-box;width:100%;border:1px solid #999;padding:1px;background:#fff}.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-arrow{display:inline-block;position:absolute;top:9px;right:8px;width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #bbb}.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols{position:relative;display:-ms-flexbox;display:flex;border-top:1px solid #aaa;overflow:hidden}.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols .tabulator-col:last-child{margin-right:-1px}.tabulator .tabulator-header .tabulator-col:first-child .tabulator-col-resize-handle.prev{display:none}.tabulator .tabulator-header .tabulator-col.ui-sortable-helper{position:absolute;background-color:#e6e6e6!important;border:1px solid #aaa}.tabulator .tabulator-header .tabulator-col .tabulator-header-filter{position:relative;box-sizing:border-box;margin-top:2px;width:100%;text-align:center}.tabulator .tabulator-header .tabulator-col .tabulator-header-filter textarea{height:auto!important}.tabulator .tabulator-header .tabulator-col .tabulator-header-filter svg{margin-top:3px}.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title{padding-right:25px}.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover{cursor:pointer;background-color:#cdcdcd}.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort=none] .tabulator-col-content .tabulator-arrow{border-top:none;border-bottom:6px solid #bbb}.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort=asc] .tabulator-col-content .tabulator-arrow{border-top:none;border-bottom:6px solid #666}.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort=desc] .tabulator-col-content .tabulator-arrow{border-top:6px solid #666;border-bottom:none}.tabulator .tabulator-header .tabulator-frozen{display:inline-block;position:absolute;z-index:1}.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left{border-right:2px solid #aaa}.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-right{border-left:2px solid #aaa}.tabulator .tabulator-header .tabulator-calcs-holder{box-sizing:border-box;min-width:200%;background:#f3f3f3!important;border-top:1px solid #aaa;border-bottom:1px solid #aaa;overflow:hidden}.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row{background:#f3f3f3!important}.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row .tabulator-col-resize-handle{display:none}.tabulator .tabulator-header .tabulator-frozen-rows-holder{min-width:200%}.tabulator .tabulator-header .tabulator-frozen-rows-holder:empty{display:none}.tabulator .tabulator-tableHolder{position:relative;width:100%;white-space:nowrap;overflow:auto;-webkit-overflow-scrolling:touch}.tabulator .tabulator-tableHolder:focus{outline:none}.tabulator .tabulator-tableHolder .tabulator-placeholder{position:absolute;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;top:0;left:0;height:100%;width:100%}.tabulator .tabulator-tableHolder .tabulator-placeholder span{display:inline-block;margin:0 auto;padding:10px;color:#ccc;font-weight:700;font-size:20px}.tabulator .tabulator-tableHolder .tabulator-table{position:relative;display:inline-block;background-color:#fff;white-space:nowrap;overflow:visible;color:#333}.tabulator .tabulator-tableHolder .tabulator-table .tabulator-row.tabulator-calcs{font-weight:700;background:#e2e2e2!important}.tabulator .tabulator-tableHolder .tabulator-table .tabulator-row.tabulator-calcs.tabulator-calcs-top{border-bottom:2px solid #aaa}.tabulator .tabulator-tableHolder .tabulator-table .tabulator-row.tabulator-calcs.tabulator-calcs-bottom{border-top:2px solid #aaa}.tabulator .tabulator-row{position:relative;box-sizing:border-box;min-height:22px;background-color:#fff}.tabulator .tabulator-row.tabulator-row-even{background-color:#efefef}.tabulator .tabulator-row.tabulator-selectable:hover{background-color:#bbb;cursor:pointer}.tabulator .tabulator-row.tabulator-selected{background-color:#9abcea}.tabulator .tabulator-row.tabulator-selected:hover{background-color:#769bcc;cursor:pointer}.tabulator .tabulator-row.tabulator-row-moving{border:1px solid #000;background:#fff}.tabulator .tabulator-row.tabulator-moving{position:absolute;border-top:1px solid #aaa;border-bottom:1px solid #aaa;pointer-events:none;z-index:2}.tabulator .tabulator-row .tabulator-row-resize-handle{position:absolute;right:0;bottom:0;left:0;height:5px}.tabulator .tabulator-row .tabulator-row-resize-handle.prev{top:0;bottom:auto}.tabulator .tabulator-row .tabulator-row-resize-handle:hover{cursor:ns-resize}.tabulator .tabulator-row .tabulator-frozen{display:inline-block;position:absolute;background-color:inherit;z-index:1}.tabulator .tabulator-row .tabulator-frozen.tabulator-frozen-left{border-right:2px solid #aaa}.tabulator .tabulator-row .tabulator-frozen.tabulator-frozen-right{border-left:2px solid #aaa}.tabulator .tabulator-row .tabulator-cell{display:inline-block;position:relative;box-sizing:border-box;padding:4px;border-right:1px solid #aaa;vertical-align:middle;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tabulator .tabulator-row .tabulator-cell.tabulator-editing{border:1px solid #1d68cd;padding:0}.tabulator .tabulator-row .tabulator-cell.tabulator-editing input,.tabulator .tabulator-row .tabulator-cell.tabulator-editing select{border:1px;background:transparent}.tabulator .tabulator-row .tabulator-cell.tabulator-validation-fail{border:1px solid #d00}.tabulator .tabulator-row .tabulator-cell.tabulator-validation-fail input,.tabulator .tabulator-row .tabulator-cell.tabulator-validation-fail select{border:1px;background:transparent;color:#d00}.tabulator .tabulator-row .tabulator-cell:first-child .tabulator-col-resize-handle.prev{display:none}.tabulator .tabulator-row .tabulator-cell.tabulator-row-handle{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none}.tabulator .tabulator-row .tabulator-cell.tabulator-row-handle .tabulator-row-handle-box{width:80%}.tabulator .tabulator-row .tabulator-cell.tabulator-row-handle .tabulator-row-handle-box .tabulator-row-handle-bar{width:100%;height:3px;margin:2px 10% 0;background:#666}.tabulator .tabulator-row.tabulator-group{box-sizing:border-box;border-bottom:1px solid #999;border-right:1px solid #aaa;border-top:1px solid #999;padding:5px;padding-left:10px;background:#ccc;font-weight:700;min-width:100%}.tabulator .tabulator-row.tabulator-group:hover{cursor:pointer;background-color:rgba(0,0,0,.1)}.tabulator .tabulator-row.tabulator-group.tabulator-group-visible .tabulator-arrow{margin-right:10px;border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #666;border-bottom:0}.tabulator .tabulator-row.tabulator-group.tabulator-group-level-1 .tabulator-arrow{margin-left:20px}.tabulator .tabulator-row.tabulator-group.tabulator-group-level-2 .tabulator-arrow{margin-left:40px}.tabulator .tabulator-row.tabulator-group.tabulator-group-level-3 .tabulator-arrow{margin-left:60px}.tabulator .tabulator-row.tabulator-group.tabulator-group-level-4 .tabulator-arrow{margin-left:80px}.tabulator .tabulator-row.tabulator-group.tabulator-group-level-5 .tabulator-arrow{margin-left:100px}.tabulator .tabulator-row.tabulator-group .tabulator-arrow{display:inline-block;width:0;height:0;margin-right:16px;border-top:6px solid transparent;border-bottom:6px solid transparent;border-right:0;border-left:6px solid #666;vertical-align:middle}.tabulator .tabulator-row.tabulator-group span{margin-left:10px;color:#d00}.tabulator .tabulator-footer{padding:5px 10px;border-top:1px solid #999;background-color:#e6e6e6;text-align:right;color:#555;font-weight:700;white-space:nowrap;-ms-user-select:none;user-select:none;-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none}.tabulator .tabulator-footer .tabulator-calcs-holder{box-sizing:border-box;width:calc("100% + 20px");margin:-5px -10px 5px;text-align:left;background:#f3f3f3!important;border-bottom:1px solid #aaa;border-top:1px solid #aaa;overflow:hidden}.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row{background:#f3f3f3!important}.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row .tabulator-col-resize-handle{display:none}.tabulator .tabulator-footer .tabulator-calcs-holder:only-child{margin-bottom:-5px;border-bottom:none}.tabulator .tabulator-footer .tabulator-pages{margin:0 7px}.tabulator .tabulator-footer .tabulator-page{display:inline-block;margin:0 2px;padding:2px 5px;border:1px solid #aaa;border-radius:3px;background:hsla(0,0%,100%,.2);color:#555;font-family:inherit;font-weight:inherit;font-size:inherit}.tabulator .tabulator-footer .tabulator-page.active{color:#d00}.tabulator .tabulator-footer .tabulator-page:disabled{opacity:.5}.tabulator .tabulator-footer .tabulator-page:not(.disabled):hover{cursor:pointer;background:rgba(0,0,0,.2);color:#fff}.tabulator .tabulator-col-resize-handle{position:absolute;right:0;top:0;bottom:0;width:5px}.tabulator .tabulator-col-resize-handle.prev{left:0;right:auto}.tabulator .tabulator-col-resize-handle:hover{cursor:ew-resize}.tabulator .tablulator-loader{position:absolute;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;top:0;left:0;z-index:3;height:100%;width:100%;background:rgba(0,0,0,.4);text-align:center}.tabulator .tablulator-loader .tabulator-loader-msg{display:inline-block;margin:0 auto;padding:10px 20px;border-radius:10px;background:#fff;font-weight:700;font-size:16px}.tabulator .tablulator-loader .tabulator-loader-msg.tabulator-loading{border:4px solid #333;color:#000}.tabulator .tablulator-loader .tabulator-loader-msg.tabulator-error{border:4px solid #d00;color:#590000}
/*# sourceMappingURL=tabulator.min.css.map */
diff --git a/lib/tabulator.min.js b/lib/tabulator.min.js
index 0b7e5e8..588da08 100644
--- a/lib/tabulator.min.js
+++ b/lib/tabulator.min.js
@@ -1,7 +1,7 @@
-/* Tabulator v3.4.4 (c) Oliver Folkerd */
-"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t,o){!function(){Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),o=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],s=0;s