1 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; };
5 ;(
function (global, factory) {
6 if ((typeof exports ===
'undefined' ?
'undefined' : _typeof(exports)) ===
'object' && typeof module !==
'undefined') {
7 module.exports = factory();
8 }
else if (typeof define ===
'function' && define.amd) {
11 global.Tabulator = factory();
13 })(
this,
function () {
20 if (!Array.prototype.findIndex) {
22 Object.defineProperty(Array.prototype,
'findIndex', {
24 value:
function value(predicate) {
31 throw new TypeError(
'"this" is null or not defined');
39 var len = o.length >>> 0;
44 if (typeof predicate !==
'function') {
46 throw new TypeError(
'predicate must be a function');
52 var thisArg = arguments[1];
78 if (predicate.call(thisArg, kValue, k, o)) {
101 if (!Array.prototype.find) {
103 Object.defineProperty(Array.prototype,
'find', {
105 value:
function value(predicate) {
112 throw new TypeError(
'"this" is null or not defined');
115 var o = Object(
this);
120 var len = o.length >>> 0;
125 if (typeof predicate !==
'function') {
127 throw new TypeError(
'predicate must be a function');
133 var thisArg = arguments[1];
159 if (predicate.call(thisArg, kValue, k, o)) {
179 var ColumnManager =
function ColumnManager(table) {
184 this.blockHozScrollEvent =
false;
186 this.headersElement = this.createHeadersElement();
188 this.element = this.createHeaderElement();
191 this.rowManager = null;
197 this.columnsByIndex = [];
200 this.columnsByField = {};
205 this.element.insertBefore(this.headersElement, this.element.firstChild);
211 ColumnManager.prototype.createHeadersElement =
function () {
213 var el = document.createElement(
"div");
215 el.classList.add(
"tabulator-headers");
220 ColumnManager.prototype.createHeaderElement =
function () {
222 var el = document.createElement(
"div");
224 el.classList.add(
"tabulator-header");
226 if (!this.table.options.headerVisible) {
228 el.classList.add(
"tabulator-header-hidden");
234 ColumnManager.prototype.initialize =
function () {
260 ColumnManager.prototype.setRowManager =
function (manager) {
262 this.rowManager = manager;
268 ColumnManager.prototype.getElement =
function () {
276 ColumnManager.prototype.getHeadersElement =
function () {
278 return this.headersElement;
296 ColumnManager.prototype.scrollHorizontal =
function (left) {
299 scrollWidth = this.element.scrollWidth - this.table.element.clientWidth;
304 this.element.scrollLeft = left;
309 if (left > scrollWidth) {
311 hozAdjust = left - scrollWidth;
313 this.element.style.marginLeft = -hozAdjust +
"px";
316 this.element.style.marginLeft = 0;
325 this.scrollLeft = left;
327 if (this.table.modExists(
"frozenColumns")) {
329 this.table.modules.frozenColumns.scrollHorizontal();
336 ColumnManager.prototype.generateColumnsFromRowData =
function (data) {
342 if (data && data.length) {
346 for (var key in row) {
356 var value = row[key];
358 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
374 if (Array.isArray(value)) {
386 if (!isNaN(value) && value !==
"") {
391 if (value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)) {
409 this.table.options.columns = cols;
411 this.setColumns(this.table.options.columns);
415 ColumnManager.prototype.setColumns =
function (cols, row) {
419 while (
self.headersElement.firstChild) {
420 self.headersElement.removeChild(
self.headersElement.firstChild);
423 self.columnsByIndex = [];
425 self.columnsByField = {};
430 if (
self.table.modExists(
"frozenColumns")) {
432 self.table.modules.frozenColumns.reset();
435 cols.forEach(
function (def, i) {
437 self._addColumn(def);
440 self._reIndexColumns();
442 if (
self.table.options.responsiveLayout &&
self.table.modExists(
"responsiveLayout",
true)) {
444 self.table.modules.responsiveLayout.initialize();
450 ColumnManager.prototype._addColumn =
function (definition, before, nextToColumn) {
452 var column =
new Column(definition,
this),
453 colEl = column.getElement(),
454 index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;
456 if (nextToColumn && index > -1) {
458 var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn());
460 var nextEl = nextToColumn.getElement();
464 this.columns.splice(parentIndex, 0, column);
466 nextEl.parentNode.insertBefore(colEl, nextEl);
469 this.columns.splice(parentIndex + 1, 0, column);
471 nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);
477 this.columns.unshift(column);
479 this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild);
482 this.columns.push(column);
484 this.headersElement.appendChild(column.getElement());
487 column.columnRendered();
493 ColumnManager.prototype.registerColumnField =
function (col) {
495 if (col.definition.field) {
497 this.columnsByField[col.definition.field] = col;
501 ColumnManager.prototype.registerColumnPosition =
function (col) {
503 this.columnsByIndex.push(col);
506 ColumnManager.prototype._reIndexColumns =
function () {
508 this.columnsByIndex = [];
510 this.columns.forEach(
function (column) {
512 column.reRegisterPosition();
519 ColumnManager.prototype._verticalAlignHeaders =
function () {
524 self.columns.forEach(
function (column) {
528 column.clearVerticalAlign();
530 height = column.getHeight();
532 if (height > minHeight) {
538 self.columns.forEach(
function (column) {
540 column.verticalAlign(
self.table.options.columnHeaderVertAlign, minHeight);
543 self.rowManager.adjustTableSize();
549 ColumnManager.prototype.findColumn =
function (subject) {
553 if ((typeof subject ===
'undefined' ?
'undefined' : _typeof(subject)) ==
"object") {
555 if (subject instanceof Column) {
561 }
else if (subject instanceof ColumnComponent) {
566 return subject._getSelf() ||
false;
567 }
else if (typeof HTMLElement !==
"undefined" && subject instanceof HTMLElement) {
572 var match =
self.columns.find(
function (column) {
574 return column.element === subject;
577 return match ||
false;
584 return this.columnsByField[subject] ||
false;
593 ColumnManager.prototype.getColumnByField =
function (field) {
595 return this.columnsByField[field];
598 ColumnManager.prototype.getColumnsByFieldRoot =
function (root) {
603 Object.keys(this.columnsByField).forEach(
function (field) {
605 var fieldRoot = field.split(
".")[0];
607 if (fieldRoot === root) {
609 matches.push(_this.columnsByField[field]);
616 ColumnManager.prototype.getColumnByIndex =
function (index) {
618 return this.columnsByIndex[index];
621 ColumnManager.prototype.getFirstVisibileColumn =
function (index) {
623 var index = this.columnsByIndex.findIndex(
function (col) {
628 return index > -1 ? this.columnsByIndex[index] :
false;
631 ColumnManager.prototype.getColumns =
function () {
636 ColumnManager.prototype.findColumnIndex =
function (column) {
638 return this.columnsByIndex.findIndex(
function (col) {
640 return column === col;
647 ColumnManager.prototype.getRealColumns =
function () {
649 return this.columnsByIndex;
655 ColumnManager.prototype.traverse =
function (callback) {
659 self.columnsByIndex.forEach(
function (column, i) {
668 ColumnManager.prototype.getDefinitions =
function (active) {
673 self.columnsByIndex.forEach(
function (column) {
675 if (!active || active && column.visible) {
677 output.push(column.getDefinition());
687 ColumnManager.prototype.getDefinitionTree =
function () {
692 self.columns.forEach(
function (column) {
694 output.push(column.getDefinition(
true));
700 ColumnManager.prototype.getComponents =
function (structured) {
704 columns = structured ?
self.columns :
self.columnsByIndex;
706 columns.forEach(
function (column) {
708 output.push(column.getComponent());
714 ColumnManager.prototype.getWidth =
function () {
718 this.columnsByIndex.forEach(
function (column) {
720 if (column.visible) {
722 width += column.getWidth();
729 ColumnManager.prototype.moveColumn =
function (from, to, after) {
731 this.moveColumnActual(from, to, after);
733 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
735 this.table.modules.responsiveLayout.initialize();
738 if (this.table.modExists(
"columnCalcs")) {
740 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
743 to.element.parentNode.insertBefore(from.element, to.element);
747 to.element.parentNode.insertBefore(to.element, from.element);
750 this._verticalAlignHeaders();
752 this.table.rowManager.reinitialize();
755 ColumnManager.prototype.moveColumnActual =
function (from, to, after) {
757 this._moveColumnInArray(this.columns, from, to, after);
759 this._moveColumnInArray(this.columnsByIndex, from, to, after,
true);
761 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
763 this.table.modules.responsiveLayout.initialize();
766 if (this.table.options.columnMoved) {
768 this.table.options.columnMoved.call(this.table, from.getComponent(), this.table.columnManager.getComponents());
771 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
773 this.table.modules.persistence.save(
"columns");
777 ColumnManager.prototype._moveColumnInArray =
function (columns, from, to, after, updateRows) {
779 var fromIndex = columns.indexOf(from),
782 if (fromIndex > -1) {
784 columns.splice(fromIndex, 1);
786 toIndex = columns.indexOf(to);
792 toIndex = toIndex + 1;
799 columns.splice(toIndex, 0, from);
803 this.table.rowManager.rows.forEach(
function (row) {
805 if (row.cells.length) {
807 var cell = row.cells.splice(fromIndex, 1)[0];
809 row.cells.splice(toIndex, 0, cell);
816 ColumnManager.prototype.scrollToColumn =
function (column, position, ifVisible) {
822 colEl = column.getElement();
824 return new Promise(
function (resolve, reject) {
826 if (typeof position ===
"undefined") {
828 position = _this2.table.options.scrollToColumnPosition;
831 if (typeof ifVisible ===
"undefined") {
833 ifVisible = _this2.table.options.scrollToColumnIfVisible;
836 if (column.visible) {
847 adjust = -_this2.element.clientWidth / 2;
853 adjust = colEl.clientWidth - _this2.headersElement.clientWidth;
864 offset = colEl.offsetLeft;
866 if (offset > 0 && offset + colEl.offsetWidth < _this2.element.clientWidth) {
875 left = colEl.offsetLeft + _this2.element.scrollLeft + adjust;
877 left = Math.max(Math.min(left, _this2.table.rowManager.element.scrollWidth - _this2.table.rowManager.element.clientWidth), 0);
879 _this2.table.rowManager.scrollHorizontal(left);
881 _this2.scrollHorizontal(left);
886 console.warn(
"Scroll Error - Column not visible");
888 reject(
"Scroll Error - Column not visible");
896 ColumnManager.prototype.generateCells =
function (row) {
902 self.columnsByIndex.forEach(
function (column) {
904 cells.push(column.generateCell(row));
913 ColumnManager.prototype.getFlexBaseWidth =
function () {
916 totalWidth =
self.table.element.clientWidth,
925 if (
self.rowManager.element.scrollHeight >
self.rowManager.element.clientHeight) {
927 totalWidth -=
self.rowManager.element.offsetWidth -
self.rowManager.element.clientWidth;
930 this.columnsByIndex.forEach(
function (column) {
932 var width, minWidth, colWidth;
934 if (column.visible) {
936 width = column.definition.width || 0;
938 minWidth = typeof column.minWidth ==
"undefined" ?
self.table.options.columnMinWidth : parseInt(column.minWidth);
940 if (typeof width ==
"string") {
942 if (width.indexOf(
"%") > -1) {
944 colWidth = totalWidth / 100 * parseInt(width);
947 colWidth = parseInt(width);
954 fixedWidth += colWidth > minWidth ? colWidth : minWidth;
961 ColumnManager.prototype.addColumn =
function (definition, before, nextToColumn) {
964 return new Promise(
function (resolve, reject) {
966 var column = _this3._addColumn(definition, before, nextToColumn);
968 _this3._reIndexColumns();
970 if (_this3.table.options.responsiveLayout && _this3.table.modExists(
"responsiveLayout",
true)) {
972 _this3.table.modules.responsiveLayout.initialize();
975 if (_this3.table.modExists(
"columnCalcs")) {
977 _this3.table.modules.columnCalcs.recalc(_this3.table.rowManager.activeRows);
982 if (_this3.table.modules.layout.getMode() !=
"fitColumns") {
984 column.reinitializeWidth();
987 _this3._verticalAlignHeaders();
989 _this3.table.rowManager.reinitialize();
998 ColumnManager.prototype.deregisterColumn =
function (column) {
1000 var field = column.getField(),
1008 delete this.columnsByField[field];
1014 index = this.columnsByIndex.indexOf(column);
1018 this.columnsByIndex.splice(index, 1);
1024 index = this.columns.indexOf(column);
1028 this.columns.splice(index, 1);
1031 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
1033 this.table.modules.responsiveLayout.initialize();
1042 ColumnManager.prototype.redraw =
function (force) {
1046 if (Tabulator.prototype.helpers.elVisible(
this.element)) {
1048 this._verticalAlignHeaders();
1051 this.table.rowManager.resetScroll();
1053 this.table.rowManager.reinitialize();
1056 if ([
"fitColumns",
"fitDataStretch"].indexOf(this.table.modules.layout.getMode()) > -1) {
1058 this.table.modules.layout.layout();
1063 this.table.modules.layout.layout();
1066 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
1068 this.table.modules.responsiveLayout.update();
1073 if (this.table.modExists(
"frozenColumns")) {
1075 this.table.modules.frozenColumns.layout();
1078 if (this.table.modExists(
"columnCalcs")) {
1080 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
1085 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
1087 this.table.modules.persistence.save(
"columns");
1090 if (this.table.modExists(
"columnCalcs")) {
1092 this.table.modules.columnCalcs.redraw();
1096 this.table.footerManager.redraw();
1101 var ColumnComponent =
function ColumnComponent(column) {
1103 this._column = column;
1105 this.type =
"ColumnComponent";
1108 ColumnComponent.prototype.getElement =
function () {
1110 return this._column.getElement();
1113 ColumnComponent.prototype.getDefinition =
function () {
1115 return this._column.getDefinition();
1118 ColumnComponent.prototype.getField =
function () {
1120 return this._column.getField();
1123 ColumnComponent.prototype.getCells =
function () {
1127 this._column.cells.forEach(
function (cell) {
1129 cells.push(cell.getComponent());
1135 ColumnComponent.prototype.getVisibility =
function () {
1137 return this._column.visible;
1140 ColumnComponent.prototype.show =
function () {
1142 if (this._column.isGroup) {
1144 this._column.columns.forEach(
function (column) {
1150 this._column.show();
1154 ColumnComponent.prototype.hide =
function () {
1156 if (this._column.isGroup) {
1158 this._column.columns.forEach(
function (column) {
1164 this._column.hide();
1168 ColumnComponent.prototype.toggle =
function () {
1170 if (this._column.visible) {
1179 ColumnComponent.prototype.delete =
function () {
1181 return this._column.delete();
1184 ColumnComponent.prototype.getSubColumns =
function () {
1188 if (this._column.columns.length) {
1190 this._column.columns.forEach(
function (column) {
1192 output.push(column.getComponent());
1199 ColumnComponent.prototype.getParentColumn =
function () {
1201 return this._column.parent instanceof Column ? this._column.parent.getComponent() :
false;
1204 ColumnComponent.prototype._getSelf =
function () {
1206 return this._column;
1209 ColumnComponent.prototype.scrollTo =
function () {
1211 return this._column.table.columnManager.scrollToColumn(this._column);
1214 ColumnComponent.prototype.getTable =
function () {
1216 return this._column.table;
1219 ColumnComponent.prototype.headerFilterFocus =
function () {
1221 if (this._column.table.modExists(
"filter",
true)) {
1223 this._column.table.modules.filter.setHeaderFilterFocus(this._column);
1227 ColumnComponent.prototype.reloadHeaderFilter =
function () {
1229 if (this._column.table.modExists(
"filter",
true)) {
1231 this._column.table.modules.filter.reloadHeaderFilter(this._column);
1235 ColumnComponent.prototype.setHeaderFilterValue =
function (value) {
1237 if (this._column.table.modExists(
"filter",
true)) {
1239 this._column.table.modules.filter.setHeaderFilterValue(this._column, value);
1243 ColumnComponent.prototype.move =
function (to, after) {
1245 var toColumn = this._column.table.columnManager.findColumn(to);
1249 this._column.table.columnManager.moveColumn(this._column, toColumn, after);
1252 console.warn(
"Move Error - No matching column found:", toColumn);
1256 ColumnComponent.prototype.getNextColumn =
function () {
1258 var nextCol = this._column.nextColumn();
1260 return nextCol ? nextCol.getComponent() :
false;
1263 ColumnComponent.prototype.getPrevColumn =
function () {
1265 var prevCol = this._column.prevColumn();
1267 return prevCol ? prevCol.getComponent() :
false;
1270 ColumnComponent.prototype.updateDefinition =
function (updates) {
1272 return this._column.updateDefinition(updates);
1275 var Column =
function Column(def, parent) {
1279 this.table = parent.table;
1281 this.definition = def;
1283 this.parent = parent;
1285 this.type =
"column";
1291 this.element = this.createElement();
1293 this.contentElement =
false;
1295 this.groupElement = this.createGroupElement();
1297 this.isGroup =
false;
1299 this.tooltip =
false;
1308 this.fieldStructure =
"";
1310 this.getFieldValue =
"";
1312 this.setFieldValue =
"";
1314 this.titleFormatterRendered =
false;
1316 this.setField(this.definition.field);
1318 if (this.table.options.invalidOptionWarnings) {
1320 this.checkDefinition();
1330 cellDblClick:
false,
1340 cellMouseEnter:
false,
1342 cellMouseLeave:
false,
1344 cellMouseOver:
false,
1346 cellMouseOut:
false,
1348 cellMouseMove:
false
1354 this.widthStyled =
"";
1356 this.minWidth = null;
1358 this.minWidthStyled =
"";
1360 this.widthFixed =
false;
1363 this.visible =
true;
1366 this._mapDepricatedFunctionality();
1372 this.isGroup =
true;
1374 def.columns.forEach(
function (def, i) {
1376 var newCol =
new Column(def,
self);
1378 self.attachColumn(newCol);
1381 self.checkColumnVisibility();
1384 parent.registerColumnField(
this);
1387 if (def.rowHandle &&
this.table.options.movableRows !==
false &&
this.table.modExists(
"moveRow")) {
1389 this.table.modules.moveRow.setHandle(
true);
1392 this._buildHeader();
1394 this.bindModuleColumns();
1397 Column.prototype.createElement =
function () {
1399 var el = document.createElement(
"div");
1401 el.classList.add(
"tabulator-col");
1403 el.setAttribute(
"role",
"columnheader");
1405 el.setAttribute(
"aria-sort",
"none");
1410 Column.prototype.createGroupElement =
function () {
1412 var el = document.createElement(
"div");
1414 el.classList.add(
"tabulator-col-group-cols");
1419 Column.prototype.checkDefinition =
function () {
1422 Object.keys(this.definition).forEach(
function (key) {
1424 if (_this4.defaultOptionList.indexOf(key) === -1) {
1426 console.warn(
"Invalid column definition option in '" + (_this4.field || _this4.definition.title) +
"' column:", key);
1431 Column.prototype.setField =
function (field) {
1435 this.fieldStructure = field ? this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field] : [];
1437 this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;
1439 this.setFieldValue = this.fieldStructure.length > 1 ? this._setNesteData : this._setFlatData;
1444 Column.prototype.registerColumnPosition =
function (column) {
1446 this.parent.registerColumnPosition(column);
1451 Column.prototype.registerColumnField =
function (column) {
1453 this.parent.registerColumnField(column);
1458 Column.prototype.reRegisterPosition =
function () {
1462 this.columns.forEach(
function (column) {
1464 column.reRegisterPosition();
1468 this.registerColumnPosition(
this);
1472 Column.prototype._mapDepricatedFunctionality =
function () {
1474 if (typeof this.definition.hideInHtml !==
"undefined") {
1476 this.definition.htmlOutput = !this.definition.hideInHtml;
1478 console.warn(
"hideInHtml column definition property is deprecated, you should now use htmlOutput");
1482 Column.prototype.setTooltip =
function () {
1485 def =
self.definition;
1489 var tooltip = def.headerTooltip || def.tooltip ===
false ? def.headerTooltip :
self.table.options.tooltipsHeader;
1493 if (tooltip ===
true) {
1497 self.table.modules.localize.bind(
"columns|" + def.field, function (value) {
1499 self.element.setAttribute(
"title", value || def.title);
1503 self.element.setAttribute(
"title", def.title);
1507 if (typeof tooltip ==
"function") {
1509 tooltip = tooltip(
self.getComponent());
1511 if (tooltip ===
false) {
1517 self.element.setAttribute(
"title", tooltip);
1521 self.element.setAttribute(
"title",
"");
1527 Column.prototype._buildHeader =
function () {
1530 def =
self.definition;
1532 while (
self.element.firstChild) {
1533 self.element.removeChild(
self.element.firstChild);
1534 }
if (def.headerVertical) {
1536 self.element.classList.add(
"tabulator-col-vertical");
1538 if (def.headerVertical ===
"flip") {
1540 self.element.classList.add(
"tabulator-col-vertical-flip");
1544 self.contentElement =
self._bindEvents();
1546 self.contentElement =
self._buildColumnHeaderContent();
1548 self.element.appendChild(
self.contentElement);
1552 self._buildGroupHeader();
1555 self._buildColumnHeader();
1562 if (
self.table.options.resizableColumns &&
self.table.modExists(
"resizeColumns")) {
1564 self.table.modules.resizeColumns.initializeColumn(
"header",
self,
self.element);
1569 if (def.headerFilter &&
self.table.modExists(
"filter") &&
self.table.modExists(
"edit")) {
1571 if (typeof def.headerFilterPlaceholder !==
"undefined" && def.field) {
1573 self.table.modules.localize.setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder);
1576 self.table.modules.filter.initializeColumn(
self);
1581 if (
self.table.modExists(
"frozenColumns")) {
1583 self.table.modules.frozenColumns.initializeColumn(
self);
1588 if (
self.table.options.movableColumns && !
self.isGroup &&
self.table.modExists(
"moveColumn")) {
1590 self.table.modules.moveColumn.initializeColumn(
self);
1595 if ((def.topCalc || def.bottomCalc) &&
self.table.modExists(
"columnCalcs")) {
1597 self.table.modules.columnCalcs.initializeColumn(
self);
1602 if (
self.table.modExists(
"persistence") &&
self.table.modules.persistence.config.columns) {
1604 self.table.modules.persistence.initializeColumn(
self);
1609 self.element.addEventListener(
"mouseenter",
function (e) {
1615 Column.prototype._bindEvents =
function () {
1618 def =
self.definition,
1625 if (typeof def.headerClick ==
"function") {
1627 self.element.addEventListener(
"click",
function (e) {
1628 def.headerClick(e,
self.getComponent());
1632 if (typeof def.headerDblClick ==
"function") {
1634 self.element.addEventListener(
"dblclick",
function (e) {
1635 def.headerDblClick(e,
self.getComponent());
1639 if (typeof def.headerContext ==
"function") {
1641 self.element.addEventListener(
"contextmenu",
function (e) {
1642 def.headerContext(e,
self.getComponent());
1648 if (typeof def.headerTap ==
"function") {
1652 self.element.addEventListener(
"touchstart",
function (e) {
1655 }, { passive:
true });
1657 self.element.addEventListener(
"touchend",
function (e) {
1661 def.headerTap(e,
self.getComponent());
1668 if (typeof def.headerDblTap ==
"function") {
1672 self.element.addEventListener(
"touchend",
function (e) {
1676 clearTimeout(dblTap);
1680 def.headerDblTap(e,
self.getComponent());
1683 dblTap = setTimeout(
function () {
1685 clearTimeout(dblTap);
1693 if (typeof def.headerTapHold ==
"function") {
1697 self.element.addEventListener(
"touchstart",
function (e) {
1699 clearTimeout(tapHold);
1701 tapHold = setTimeout(
function () {
1703 clearTimeout(tapHold);
1709 def.headerTapHold(e,
self.getComponent());
1711 }, { passive:
true });
1713 self.element.addEventListener(
"touchend",
function (e) {
1715 clearTimeout(tapHold);
1723 if (typeof def.cellClick ==
"function") {
1725 self.cellEvents.cellClick = def.cellClick;
1728 if (typeof def.cellDblClick ==
"function") {
1730 self.cellEvents.cellDblClick = def.cellDblClick;
1733 if (typeof def.cellContext ==
"function") {
1735 self.cellEvents.cellContext = def.cellContext;
1740 if (typeof def.cellMouseEnter ==
"function") {
1742 self.cellEvents.cellMouseEnter = def.cellMouseEnter;
1745 if (typeof def.cellMouseLeave ==
"function") {
1747 self.cellEvents.cellMouseLeave = def.cellMouseLeave;
1750 if (typeof def.cellMouseOver ==
"function") {
1752 self.cellEvents.cellMouseOver = def.cellMouseOver;
1755 if (typeof def.cellMouseOut ==
"function") {
1757 self.cellEvents.cellMouseOut = def.cellMouseOut;
1760 if (typeof def.cellMouseMove ==
"function") {
1762 self.cellEvents.cellMouseMove = def.cellMouseMove;
1767 if (typeof def.cellTap ==
"function") {
1769 self.cellEvents.cellTap = def.cellTap;
1772 if (typeof def.cellDblTap ==
"function") {
1774 self.cellEvents.cellDblTap = def.cellDblTap;
1777 if (typeof def.cellTapHold ==
"function") {
1779 self.cellEvents.cellTapHold = def.cellTapHold;
1784 if (typeof def.cellEdited ==
"function") {
1786 self.cellEvents.cellEdited = def.cellEdited;
1789 if (typeof def.cellEditing ==
"function") {
1791 self.cellEvents.cellEditing = def.cellEditing;
1794 if (typeof def.cellEditCancelled ==
"function") {
1796 self.cellEvents.cellEditCancelled = def.cellEditCancelled;
1802 Column.prototype._buildColumnHeader =
function () {
1805 def =
self.definition,
1811 if (table.modExists(
"sort")) {
1813 table.modules.sort.initializeColumn(
self,
self.contentElement);
1818 if (table.modExists(
"format")) {
1820 table.modules.format.initializeColumn(
self);
1825 if (typeof def.editor !=
"undefined" && table.modExists(
"edit")) {
1827 table.modules.edit.initializeColumn(
self);
1832 if (typeof def.validator !=
"undefined" && table.modExists(
"validate")) {
1834 table.modules.validate.initializeColumn(
self);
1839 if (table.modExists(
"mutator")) {
1841 table.modules.mutator.initializeColumn(
self);
1846 if (table.modExists(
"accessor")) {
1848 table.modules.accessor.initializeColumn(
self);
1853 if (_typeof(table.options.responsiveLayout) && table.modExists(
"responsiveLayout")) {
1855 table.modules.responsiveLayout.initializeColumn(
self);
1860 if (typeof def.visible !=
"undefined") {
1875 var classeNames = def.cssClass.split(
" ");
1877 classeNames.forEach(
function (className) {
1879 self.element.classList.add(className);
1885 this.element.setAttribute(
"tabulator-field", def.field);
1890 self.setMinWidth(typeof def.minWidth ==
"undefined" ?
self.table.options.columnMinWidth : parseInt(def.minWidth));
1892 self.reinitializeWidth();
1896 self.tooltip =
self.definition.tooltip ||
self.definition.tooltip ===
false ?
self.definition.tooltip :
self.table.options.tooltips;
1900 self.hozAlign = typeof
self.definition.align ==
"undefined" ?
"" :
self.definition.align;
1903 Column.prototype._buildColumnHeaderContent =
function () {
1906 def =
self.definition,
1909 var contentElement = document.createElement(
"div");
1911 contentElement.classList.add(
"tabulator-col-content");
1913 contentElement.appendChild(
self._buildColumnHeaderTitle());
1915 return contentElement;
1920 Column.prototype._buildColumnHeaderTitle =
function () {
1923 def =
self.definition,
1927 var titleHolderElement = document.createElement(
"div");
1929 titleHolderElement.classList.add(
"tabulator-col-title");
1931 if (def.editableTitle) {
1933 var titleElement = document.createElement(
"input");
1935 titleElement.classList.add(
"tabulator-title-editor");
1937 titleElement.addEventListener(
"click",
function (e) {
1939 e.stopPropagation();
1941 titleElement.focus();
1944 titleElement.addEventListener(
"change",
function () {
1946 def.title = titleElement.value;
1948 table.options.columnTitleChanged.call(
self.table,
self.getComponent());
1951 titleHolderElement.appendChild(titleElement);
1955 table.modules.localize.bind(
"columns|" + def.field, function (text) {
1957 titleElement.value = text || def.title ||
" ";
1961 titleElement.value = def.title ||
" ";
1967 table.modules.localize.bind(
"columns|" + def.field, function (text) {
1969 self._formatColumnHeaderTitle(titleHolderElement, text || def.title ||
" ");
1973 self._formatColumnHeaderTitle(titleHolderElement, def.title ||
" ");
1977 return titleHolderElement;
1980 Column.prototype._formatColumnHeaderTitle =
function (el, title) {
1983 var formatter, contents, params, mockCell, onRendered;
1985 if (this.definition.titleFormatter &&
this.table.modExists(
"format")) {
1987 formatter = this.table.modules.format.getFormatter(this.definition.titleFormatter);
1989 onRendered =
function onRendered(callback) {
1991 _this5.titleFormatterRendered = callback;
1996 getValue:
function getValue() {
2001 getElement:
function getElement() {
2008 params = this.definition.titleFormatterParams || {};
2010 params = typeof params ===
"function" ? params() : params;
2012 contents = formatter.call(this.table.modules.format, mockCell, params, onRendered);
2014 switch (typeof contents ===
'undefined' ?
'undefined' : _typeof(contents)) {
2018 if (contents instanceof Node) {
2020 el.appendChild(contents);
2025 console.warn(
"Format Error - Title formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", contents);
2040 el.innerHTML = contents;
2045 el.innerHTML = title;
2051 Column.prototype._buildGroupHeader =
function () {
2054 this.element.classList.add(
"tabulator-col-group");
2056 this.element.setAttribute(
"role",
"columngroup");
2058 this.element.setAttribute(
"aria-title", this.definition.title);
2062 if (this.definition.cssClass) {
2064 var classeNames = this.definition.cssClass.split(
" ");
2066 classeNames.forEach(
function (className) {
2068 _this6.element.classList.add(className);
2072 this.element.appendChild(this.groupElement);
2077 Column.prototype._getFlatData =
function (data) {
2079 return data[this.field];
2084 Column.prototype._getNestedData =
function (data) {
2087 structure = this.fieldStructure,
2088 length = structure.length,
2091 for (var i = 0; i < length; i++) {
2093 dataObj = dataObj[structure[i]];
2108 Column.prototype._setFlatData =
function (data, value) {
2112 data[this.field] = value;
2118 Column.prototype._setNesteData =
function (data, value) {
2121 structure = this.fieldStructure,
2122 length = structure.length;
2124 for (var i = 0; i < length; i++) {
2126 if (i == length - 1) {
2128 dataObj[structure[i]] = value;
2131 if (!dataObj[structure[i]]) {
2133 dataObj[structure[i]] = {};
2136 dataObj = dataObj[structure[i]];
2143 Column.prototype.attachColumn =
function (column) {
2147 if (
self.groupElement) {
2149 self.columns.push(column);
2151 self.groupElement.appendChild(column.getElement());
2154 console.warn(
"Column Warning - Column being attached to another column instead of column group");
2160 Column.prototype.verticalAlign =
function (alignment, height) {
2164 var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : height || this.parent.getHeadersElement().clientHeight;
2169 this.element.style.height = parentHeight +
"px";
2173 this.groupElement.style.minHeight = parentHeight - this.contentElement.offsetHeight +
"px";
2178 if (!this.isGroup && alignment !==
"top") {
2180 if (alignment ===
"bottom") {
2182 this.element.style.paddingTop = this.element.clientHeight - this.contentElement.offsetHeight +
"px";
2185 this.element.style.paddingTop = (this.element.clientHeight - this.contentElement.offsetHeight) / 2 +
"px";
2189 this.columns.forEach(
function (column) {
2191 column.verticalAlign(alignment);
2197 Column.prototype.clearVerticalAlign =
function () {
2199 this.element.style.paddingTop =
"";
2201 this.element.style.height =
"";
2203 this.element.style.minHeight =
"";
2205 this.groupElement.style.minHeight =
"";
2207 this.columns.forEach(
function (column) {
2209 column.clearVerticalAlign();
2213 Column.prototype.bindModuleColumns =
function () {
2217 if (this.definition.formatter ==
"rownum") {
2219 this.table.rowManager.rowNumColumn =
this;
2228 Column.prototype.getElement =
function () {
2230 return this.element;
2235 Column.prototype.getGroupElement =
function () {
2237 return this.groupElement;
2242 Column.prototype.getField =
function () {
2249 Column.prototype.getFirstColumn =
function () {
2251 if (!this.isGroup) {
2256 if (this.columns.length) {
2258 return this.columns[0].getFirstColumn();
2268 Column.prototype.getLastColumn =
function () {
2270 if (!this.isGroup) {
2275 if (this.columns.length) {
2277 return this.columns[this.columns.length - 1].getLastColumn();
2287 Column.prototype.getColumns =
function () {
2289 return this.columns;
2294 Column.prototype.getCells =
function () {
2301 Column.prototype.getTopColumn =
function () {
2303 if (this.parent.isGroup) {
2305 return this.parent.getTopColumn();
2314 Column.prototype.getDefinition =
function (updateBranches) {
2318 if (this.isGroup && updateBranches) {
2320 this.columns.forEach(
function (column) {
2322 colDefs.push(column.getDefinition(
true));
2325 this.definition.columns = colDefs;
2328 return this.definition;
2334 Column.prototype.checkColumnVisibility =
function () {
2336 var visible =
false;
2338 this.columns.forEach(
function (column) {
2340 if (column.visible) {
2350 this.parent.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
false);
2359 Column.prototype.show =
function (silent, responsiveToggle) {
2361 if (!this.visible) {
2363 this.visible =
true;
2365 this.element.style.display =
"";
2367 if (this.parent.isGroup) {
2369 this.parent.checkColumnVisibility();
2372 this.cells.forEach(
function (cell) {
2377 if (!this.isGroup && this.width === null) {
2379 this.reinitializeWidth();
2382 this.table.columnManager._verticalAlignHeaders();
2384 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
2386 this.table.modules.persistence.save(
"columns");
2389 if (!responsiveToggle && this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
2391 this.table.modules.responsiveLayout.updateColumnVisibility(
this, this.visible);
2396 this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
true);
2399 if (this.parent.isGroup) {
2401 this.parent.matchChildWidths();
2408 Column.prototype.hide =
function (silent, responsiveToggle) {
2412 this.visible =
false;
2414 this.element.style.display =
"none";
2416 this.table.columnManager._verticalAlignHeaders();
2418 if (this.parent.isGroup) {
2420 this.parent.checkColumnVisibility();
2423 this.cells.forEach(
function (cell) {
2428 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
2430 this.table.modules.persistence.save(
"columns");
2433 if (!responsiveToggle && this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
2435 this.table.modules.responsiveLayout.updateColumnVisibility(
this, this.visible);
2440 this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
false);
2443 if (this.parent.isGroup) {
2445 this.parent.matchChildWidths();
2450 Column.prototype.matchChildWidths =
function () {
2454 if (this.contentElement && this.columns.length) {
2456 this.columns.forEach(
function (column) {
2458 if (column.visible) {
2460 childWidth += column.getWidth();
2464 this.contentElement.style.maxWidth = childWidth - 1 +
"px";
2468 Column.prototype.setWidth =
function (width) {
2470 this.widthFixed =
true;
2472 this.setWidthActual(width);
2475 Column.prototype.setWidthActual =
function (width) {
2479 width = Math.floor(this.table.element.clientWidth / 100 * parseInt(width));
2482 width = Math.max(this.minWidth, width);
2486 this.widthStyled = width ? width +
"px" :
"";
2488 this.element.style.width = this.widthStyled;
2490 if (!this.isGroup) {
2492 this.cells.forEach(
function (cell) {
2498 if (this.parent.isGroup) {
2500 this.parent.matchChildWidths();
2505 if (this.table.modExists(
"frozenColumns")) {
2507 this.table.modules.frozenColumns.layout();
2511 Column.prototype.checkCellHeights =
function () {
2515 this.cells.forEach(
function (cell) {
2517 if (cell.row.heightInitialized) {
2519 if (cell.row.getElement().offsetParent !== null) {
2521 rows.push(cell.row);
2523 cell.row.clearCellHeight();
2526 cell.row.heightInitialized =
false;
2531 rows.forEach(
function (row) {
2536 rows.forEach(
function (row) {
2538 row.setCellHeight();
2542 Column.prototype.getWidth =
function () {
2549 Column.prototype.getHeight =
function () {
2551 return this.element.offsetHeight;
2554 Column.prototype.setMinWidth =
function (minWidth) {
2556 this.minWidth = minWidth;
2558 this.minWidthStyled = minWidth ? minWidth +
"px" :
"";
2560 this.element.style.minWidth = this.minWidthStyled;
2562 this.cells.forEach(
function (cell) {
2568 Column.prototype.delete =
function () {
2571 return new Promise(
function (resolve, reject) {
2573 if (_this7.isGroup) {
2575 _this7.columns.forEach(function (column) {
2581 var cellCount = _this7.cells.length;
2583 for (var i = 0; i < cellCount; i++) {
2585 _this7.cells[0].delete();
2588 _this7.element.parentNode.removeChild(_this7.element);
2590 _this7.table.columnManager.deregisterColumn(_this7);
2596 Column.prototype.columnRendered =
function () {
2598 if (this.titleFormatterRendered) {
2600 this.titleFormatterRendered();
2609 Column.prototype.generateCell =
function (row) {
2613 var cell =
new Cell(
self, row);
2615 this.cells.push(cell);
2620 Column.prototype.nextColumn =
function () {
2622 var index = this.table.columnManager.findColumnIndex(
this);
2624 return index > -1 ? this._nextVisibleColumn(index + 1) : false;
2627 Column.prototype._nextVisibleColumn =
function (index) {
2629 var column = this.table.columnManager.getColumnByIndex(index);
2631 return !column || column.visible ? column : this._nextVisibleColumn(index + 1);
2634 Column.prototype.prevColumn =
function () {
2636 var index = this.table.columnManager.findColumnIndex(
this);
2638 return index > -1 ? this._prevVisibleColumn(index - 1) : false;
2641 Column.prototype._prevVisibleColumn =
function (index) {
2643 var column = this.table.columnManager.getColumnByIndex(index);
2645 return !column || column.visible ? column : this._prevVisibleColumn(index - 1);
2648 Column.prototype.reinitializeWidth =
function (force) {
2650 this.widthFixed =
false;
2654 if (typeof this.definition.width !==
"undefined" && !force) {
2656 this.setWidth(this.definition.width);
2661 if (this.table.modExists(
"filter")) {
2663 this.table.modules.filter.hideHeaderFilterElements();
2670 if (this.table.modExists(
"filter")) {
2672 this.table.modules.filter.showHeaderFilterElements();
2678 Column.prototype.fitToData =
function () {
2682 if (!this.widthFixed) {
2684 this.element.style.width =
"";
2686 self.cells.forEach(
function (cell) {
2692 var maxWidth = this.element.offsetWidth;
2694 if (!
self.width || !this.widthFixed) {
2696 self.cells.forEach(
function (cell) {
2698 var width = cell.getWidth();
2700 if (width > maxWidth) {
2708 self.setWidthActual(maxWidth + 1);
2713 Column.prototype.updateDefinition =
function (updates) {
2716 return new Promise(
function (resolve, reject) {
2720 if (!_this8.isGroup) {
2722 definition = Object.assign({}, _this8.getDefinition());
2724 definition = Object.assign(definition, updates);
2726 _this8.table.columnManager.addColumn(definition,
false, _this8).then(
function (column) {
2728 if (definition.field == _this8.field) {
2730 _this8.field =
false;
2733 _this8.delete().then(
function () {
2735 resolve(column.getComponent());
2736 }).
catch(
function (err) {
2740 }).
catch(
function (err) {
2746 console.warn(
"Column Update Error - The updateDefintion function is only available on columns, not column groups");
2748 reject(
"Column Update Error - The updateDefintion function is only available on columns, not column groups");
2753 Column.prototype.deleteCell =
function (cell) {
2755 var index = this.cells.indexOf(cell);
2759 this.cells.splice(index, 1);
2763 Column.prototype.defaultOptionList = [
"title",
"field",
"columns",
"visible",
"align",
"width",
"minWidth",
"widthGrow",
"widthShrink",
"resizable",
"frozen",
"responsive",
"tooltip",
"cssClass",
"rowHandle",
"hideInHtml",
"print",
"htmlOutput",
"sorter",
"sorterParams",
"formatter",
"formatterParams",
"variableHeight",
"editable",
"editor",
"editorParams",
"validator",
"mutator",
"mutatorParams",
"mutatorData",
"mutatorDataParams",
"mutatorEdit",
"mutatorEditParams",
"mutatorClipboard",
"mutatorClipboardParams",
"accessor",
"accessorParams",
"accessorData",
"accessorDataParams",
"accessorDownload",
"accessorDownloadParams",
"accessorClipboard",
"accessorClipboardParams",
"clipboard",
"download",
"downloadTitle",
"topCalc",
"topCalcParams",
"topCalcFormatter",
"topCalcFormatterParams",
"bottomCalc",
"bottomCalcParams",
"bottomCalcFormatter",
"bottomCalcFormatterParams",
"cellClick",
"cellDblClick",
"cellContext",
"cellTap",
"cellDblTap",
"cellTapHold",
"cellMouseEnter",
"cellMouseLeave",
"cellMouseOver",
"cellMouseOut",
"cellMouseMove",
"cellEditing",
"cellEdited",
"cellEditCancelled",
"headerSort",
"headerSortStartingDir",
"headerSortTristate",
"headerClick",
"headerDblClick",
"headerContext",
"headerTap",
"headerDblTap",
"headerTapHold",
"headerTooltip",
"headerVertical",
"editableTitle",
"titleFormatter",
"titleFormatterParams",
"headerFilter",
"headerFilterPlaceholder",
"headerFilterParams",
"headerFilterEmptyCheck",
"headerFilterFunc",
"headerFilterFuncParams",
"headerFilterLiveFilter",
"print"];
2770 Column.prototype.getComponent =
function () {
2772 return new ColumnComponent(
this);
2775 var RowManager =
function RowManager(table) {
2779 this.element = this.createHolderElement();
2781 this.tableElement = this.createTableElement();
2783 this.columnManager = null;
2788 this.firstRender =
false;
2790 this.renderMode =
"classic";
2795 this.activeRows = [];
2797 this.activeRowsCount = 0;
2800 this.displayRows = [];
2802 this.displayRowsCount = 0;
2807 this.scrollLeft = 0;
2809 this.vDomRowHeight = 20;
2814 this.vDomBottom = 0;
2817 this.vDomScrollPosTop = 0;
2819 this.vDomScrollPosBottom = 0;
2822 this.vDomTopPad = 0;
2824 this.vDomBottomPad = 0;
2827 this.vDomMaxRenderChain = 90;
2830 this.vDomWindowBuffer = 0;
2833 this.vDomWindowMinTotalRows = 20;
2835 this.vDomWindowMinMarginRows = 5;
2838 this.vDomTopNewRows = [];
2840 this.vDomBottomNewRows = [];
2843 this.rowNumColumn =
false;
2846 this.redrawBlock =
false;
2848 this.redrawBlockRestoreConfig =
false;
2850 this.redrawBlockRederInPosition =
false;
2856 RowManager.prototype.createHolderElement =
function () {
2858 var el = document.createElement(
"div");
2860 el.classList.add(
"tabulator-tableHolder");
2862 el.setAttribute(
"tabindex", 0);
2867 RowManager.prototype.createTableElement =
function () {
2869 var el = document.createElement(
"div");
2871 el.classList.add(
"tabulator-table");
2878 RowManager.prototype.getElement =
function () {
2880 return this.element;
2885 RowManager.prototype.getTableElement =
function () {
2887 return this.tableElement;
2892 RowManager.prototype.getRowPosition =
function (row, active) {
2896 return this.activeRows.indexOf(row);
2899 return this.rows.indexOf(row);
2905 RowManager.prototype.setColumnManager =
function (manager) {
2907 this.columnManager = manager;
2910 RowManager.prototype.initialize =
function () {
2914 self.setRenderMode();
2918 self.element.appendChild(
self.tableElement);
2920 self.firstRender =
true;
2924 self.element.addEventListener(
"scroll",
function () {
2926 var left =
self.element.scrollLeft;
2930 if (
self.scrollLeft != left) {
2932 self.columnManager.scrollHorizontal(left);
2934 if (
self.table.options.groupBy) {
2936 self.table.modules.groupRows.scrollHeaders(left);
2939 if (
self.table.modExists(
"columnCalcs")) {
2941 self.table.modules.columnCalcs.scrollHorizontal(left);
2944 self.table.options.scrollHorizontal(left);
2947 self.scrollLeft = left;
2952 if (this.renderMode ===
"virtual") {
2954 self.element.addEventListener(
"scroll",
function () {
2956 var top =
self.element.scrollTop;
2958 var dir =
self.scrollTop > top;
2962 if (
self.scrollTop != top) {
2964 self.scrollTop = top;
2966 self.scrollVertical(dir);
2968 if (
self.table.options.ajaxProgressiveLoad ==
"scroll") {
2970 self.table.modules.ajax.nextPage(
self.element.scrollHeight -
self.element.clientHeight - top);
2973 self.table.options.scrollVertical(top);
2976 self.scrollTop = top;
2985 RowManager.prototype.findRow =
function (subject) {
2989 if ((typeof subject ===
'undefined' ?
'undefined' : _typeof(subject)) ==
"object") {
2991 if (subject instanceof Row) {
2996 }
else if (subject instanceof RowComponent) {
3000 return subject._getSelf() ||
false;
3001 }
else if (typeof HTMLElement !==
"undefined" && subject instanceof HTMLElement) {
3005 var match =
self.rows.find(
function (row) {
3007 return row.element === subject;
3010 return match ||
false;
3012 }
else if (typeof subject ==
"undefined" || subject === null) {
3019 var _match =
self.rows.find(
function (row) {
3021 return row.data[
self.table.options.index] == subject;
3024 return _match ||
false;
3033 RowManager.prototype.getRowFromDataObject =
function (data) {
3035 var match = this.rows.find(
function (row) {
3037 return row.data === data;
3040 return match ||
false;
3043 RowManager.prototype.getRowFromPosition =
function (position, active) {
3047 return this.activeRows[position];
3050 return this.rows[position];
3054 RowManager.prototype.scrollToRow =
function (row, position, ifVisible) {
3057 var rowIndex = this.getDisplayRows().indexOf(row),
3058 rowEl = row.getElement(),
3062 return new Promise(
function (resolve, reject) {
3064 if (rowIndex > -1) {
3066 if (typeof position ===
"undefined") {
3068 position = _this9.table.options.scrollToRowPosition;
3071 if (typeof ifVisible ===
"undefined") {
3073 ifVisible = _this9.table.options.scrollToRowIfVisible;
3076 if (position ===
"nearest") {
3078 switch (_this9.renderMode) {
3082 rowTop = Tabulator.prototype.helpers.elOffset(rowEl).top;
3084 position = Math.abs(_this9.element.scrollTop - rowTop) > Math.abs(_this9.element.scrollTop + _this9.element.clientHeight - rowTop) ?
"bottom" :
"top";
3090 position = Math.abs(_this9.vDomTop - rowIndex) > Math.abs(_this9.vDomBottom - rowIndex) ?
"bottom" :
"top";
3101 if (Tabulator.prototype.helpers.elVisible(rowEl)) {
3103 offset = Tabulator.prototype.helpers.elOffset(rowEl).top - Tabulator.prototype.helpers.elOffset(_this9.element).top;
3105 if (offset > 0 && offset < _this9.element.clientHeight - rowEl.offsetHeight) {
3114 switch (_this9.renderMode) {
3118 _this9.element.scrollTop = Tabulator.prototype.helpers.elOffset(rowEl).top - Tabulator.prototype.helpers.elOffset(_this9.element).top + _this9.element.scrollTop;
3124 _this9._virtualRenderFill(rowIndex,
true);
3138 if (_this9.element.scrollHeight - _this9.element.scrollTop == _this9.element.clientHeight) {
3140 _this9.element.scrollTop = _this9.element.scrollTop + (rowEl.offsetTop - _this9.element.scrollTop) - (_this9.element.scrollHeight - rowEl.offsetTop) / 2;
3143 _this9.element.scrollTop = _this9.element.scrollTop - _this9.element.clientHeight / 2;
3150 if (_this9.element.scrollHeight - _this9.element.scrollTop == _this9.element.clientHeight) {
3152 _this9.element.scrollTop = _this9.element.scrollTop - (_this9.element.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight;
3155 _this9.element.scrollTop = _this9.element.scrollTop - _this9.element.clientHeight + rowEl.offsetHeight;
3165 console.warn(
"Scroll Error - Row not visible");
3167 reject(
"Scroll Error - Row not visible");
3175 RowManager.prototype.setData =
function (data, renderInPosition) {
3180 return new Promise(
function (resolve, reject) {
3182 if (renderInPosition && _this10.getDisplayRows().length) {
3184 if (
self.table.options.pagination) {
3186 self._setDataActual(data,
true);
3189 _this10.reRenderInPosition(
function () {
3191 self._setDataActual(data);
3196 if (_this10.table.options.autoColumns) {
3198 _this10.table.columnManager.generateColumnsFromRowData(data);
3201 _this10.resetScroll();
3203 _this10._setDataActual(data);
3210 RowManager.prototype._setDataActual =
function (data, renderInPosition) {
3214 self.table.options.dataLoading.call(this.table, data);
3216 this._wipeElements();
3218 if (this.table.options.history &&
this.table.modExists(
"history")) {
3220 this.table.modules.history.clear();
3223 if (Array.isArray(data)) {
3225 if (this.table.modExists(
"selectRow")) {
3227 this.table.modules.selectRow.clearSelectionData();
3230 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {
3232 this.table.modules.reactiveData.watchData(data);
3235 data.forEach(
function (def, i) {
3237 if (def && (typeof def ===
'undefined' ?
'undefined' : _typeof(def)) ===
"object") {
3239 var row =
new Row(def,
self);
3241 self.rows.push(row);
3244 console.warn(
"Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);
3248 self.table.options.dataLoaded.call(this.table, data);
3250 self.refreshActiveData(
false,
false, renderInPosition);
3253 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);
3257 RowManager.prototype._wipeElements =
function () {
3259 this.rows.forEach(
function (row) {
3264 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
3266 this.table.modules.groupRows.wipe();
3272 RowManager.prototype.deleteRow =
function (row, blockRedraw) {
3274 var allIndex = this.rows.indexOf(row),
3275 activeIndex = this.activeRows.indexOf(row);
3277 if (activeIndex > -1) {
3279 this.activeRows.splice(activeIndex, 1);
3282 if (allIndex > -1) {
3284 this.rows.splice(allIndex, 1);
3287 this.setActiveRows(this.activeRows);
3289 this.displayRowIterator(
function (rows) {
3291 var displayIndex = rows.indexOf(row);
3293 if (displayIndex > -1) {
3295 rows.splice(displayIndex, 1);
3301 this.reRenderInPosition();
3304 this.table.options.rowDeleted.call(this.table, row.getComponent());
3306 this.table.options.dataEdited.call(this.table, this.getData());
3308 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
3310 this.table.modules.groupRows.updateGroupRows(
true);
3311 }
else if (this.table.options.pagination &&
this.table.modExists(
"page")) {
3313 this.refreshActiveData(
false,
false,
true);
3316 if (this.table.options.pagination &&
this.table.modExists(
"page")) {
3318 this.refreshActiveData(
"page");
3323 RowManager.prototype.addRow =
function (data, pos, index, blockRedraw) {
3325 var row = this.addRowActual(data, pos, index, blockRedraw);
3327 if (this.table.options.history &&
this.table.modExists(
"history")) {
3329 this.table.modules.history.action(
"rowAdd", row, { data: data, pos: pos, index: index });
3337 RowManager.prototype.addRows =
function (data, pos, index) {
3344 return new Promise(
function (resolve, reject) {
3346 pos = _this11.findAddRowPos(pos);
3348 if (!Array.isArray(data)) {
3353 length = data.length - 1;
3355 if (typeof index ==
"undefined" && pos || typeof index !==
"undefined" && !pos) {
3360 data.forEach(
function (item, i) {
3362 var row =
self.addRow(item, pos, index,
true);
3367 if (_this11.table.options.groupBy && _this11.table.modExists(
"groupRows")) {
3369 _this11.table.modules.groupRows.updateGroupRows(
true);
3370 }
else if (_this11.table.options.pagination && _this11.table.modExists(
"page")) {
3372 _this11.refreshActiveData(
false,
false,
true);
3375 _this11.reRenderInPosition();
3380 if (_this11.table.modExists(
"columnCalcs")) {
3382 _this11.table.modules.columnCalcs.recalc(_this11.table.rowManager.activeRows);
3389 RowManager.prototype.findAddRowPos =
function (pos) {
3391 if (typeof pos ===
"undefined") {
3393 pos = this.table.options.addRowPos;
3396 if (pos ===
"pos") {
3401 if (pos ===
"bottom") {
3409 RowManager.prototype.addRowActual =
function (data, pos, index, blockRedraw) {
3411 var row = data instanceof Row ? data :
new Row(data || {},
this),
3412 top = this.findAddRowPos(pos),
3415 if (!index && this.table.options.pagination &&
this.table.options.paginationAddRow ==
"page") {
3417 dispRows = this.getDisplayRows();
3421 if (dispRows.length) {
3423 index = dispRows[0];
3426 if (this.activeRows.length) {
3428 index = this.activeRows[this.activeRows.length - 1];
3435 if (dispRows.length) {
3437 index = dispRows[dispRows.length - 1];
3439 top = dispRows.length < this.table.modules.page.getPageSize() ?
false :
true;
3446 index = this.findRow(index);
3449 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
3451 this.table.modules.groupRows.assignRowToGroup(row);
3453 var groupRows = row.getGroup().rows;
3455 if (groupRows.length > 1) {
3457 if (!index || index && groupRows.indexOf(index) == -1) {
3461 if (groupRows[0] !== row) {
3463 index = groupRows[0];
3465 this._moveRowInArray(row.getGroup().rows, row, index, !top);
3469 if (groupRows[groupRows.length - 1] !== row) {
3471 index = groupRows[groupRows.length - 1];
3473 this._moveRowInArray(row.getGroup().rows, row, index, !top);
3478 this._moveRowInArray(row.getGroup().rows, row, index, !top);
3485 var allIndex = this.rows.indexOf(index),
3486 activeIndex = this.activeRows.indexOf(index);
3488 this.displayRowIterator(
function (rows) {
3490 var displayIndex = rows.indexOf(index);
3492 if (displayIndex > -1) {
3494 rows.splice(top ? displayIndex : displayIndex + 1, 0, row);
3498 if (activeIndex > -1) {
3500 this.activeRows.splice(top ? activeIndex : activeIndex + 1, 0, row);
3503 if (allIndex > -1) {
3505 this.rows.splice(top ? allIndex : allIndex + 1, 0, row);
3511 this.displayRowIterator(
function (rows) {
3516 this.activeRows.unshift(row);
3518 this.rows.unshift(row);
3521 this.displayRowIterator(
function (rows) {
3526 this.activeRows.push(row);
3528 this.rows.push(row);
3532 this.setActiveRows(this.activeRows);
3534 this.table.options.rowAdded.call(this.table, row.getComponent());
3536 this.table.options.dataEdited.call(this.table, this.getData());
3540 this.reRenderInPosition();
3546 RowManager.prototype.moveRow =
function (from, to, after) {
3548 if (this.table.options.history &&
this.table.modExists(
"history")) {
3550 this.table.modules.history.action(
"rowMove", from, { pos: this.getRowPosition(from), to: to, after: after });
3553 this.moveRowActual(from, to, after);
3555 this.table.options.rowMoved.call(this.table, from.getComponent());
3558 RowManager.prototype.moveRowActual =
function (from, to, after) {
3562 this._moveRowInArray(this.rows, from, to, after);
3564 this._moveRowInArray(this.activeRows, from, to, after);
3566 this.displayRowIterator(
function (rows) {
3568 self._moveRowInArray(rows, from, to, after);
3571 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
3573 var toGroup = to.getGroup();
3575 var fromGroup = from.getGroup();
3577 if (toGroup === fromGroup) {
3579 this._moveRowInArray(toGroup.rows, from, to, after);
3584 fromGroup.removeRow(from);
3587 toGroup.insertRow(from, to, after);
3592 RowManager.prototype._moveRowInArray =
function (rows, from, to, after) {
3594 var fromIndex, toIndex, start, end;
3598 fromIndex = rows.indexOf(from);
3600 if (fromIndex > -1) {
3602 rows.splice(fromIndex, 1);
3604 toIndex = rows.indexOf(to);
3610 rows.splice(toIndex + 1, 0, from);
3613 rows.splice(toIndex, 0, from);
3617 rows.splice(fromIndex, 0, from);
3623 if (rows === this.getDisplayRows()) {
3625 start = fromIndex < toIndex ? fromIndex : toIndex;
3627 end = toIndex > fromIndex ? toIndex : fromIndex + 1;
3629 for (var i = start; i <= end; i++) {
3633 this.styleRow(rows[i], i);
3640 RowManager.prototype.clearData =
function () {
3645 RowManager.prototype.getRowIndex =
function (row) {
3647 return this.findRowIndex(row, this.rows);
3650 RowManager.prototype.getDisplayRowIndex =
function (row) {
3652 var index = this.getDisplayRows().indexOf(row);
3654 return index > -1 ? index :
false;
3657 RowManager.prototype.nextDisplayRow =
function (row, rowOnly) {
3659 var index = this.getDisplayRowIndex(row),
3662 if (index !==
false && index < this.displayRowsCount - 1) {
3664 nextRow = this.getDisplayRows()[index + 1];
3667 if (nextRow && (!(nextRow instanceof Row) || nextRow.type !=
"row")) {
3669 return this.nextDisplayRow(nextRow, rowOnly);
3675 RowManager.prototype.prevDisplayRow =
function (row, rowOnly) {
3677 var index = this.getDisplayRowIndex(row),
3682 prevRow = this.getDisplayRows()[index - 1];
3685 if (prevRow && (!(prevRow instanceof Row) || prevRow.type !=
"row")) {
3687 return this.prevDisplayRow(prevRow, rowOnly);
3693 RowManager.prototype.findRowIndex =
function (row, list) {
3697 row = this.findRow(row);
3701 rowIndex = list.indexOf(row);
3703 if (rowIndex > -1) {
3712 RowManager.prototype.getData =
function (active, transform) {
3715 rows = this.getRows(active);
3717 rows.forEach(
function (row) {
3719 output.push(row.getData(transform ||
"data"));
3725 RowManager.prototype.getComponents =
function (active) {
3728 rows = this.getRows(active);
3730 rows.forEach(
function (row) {
3732 output.push(row.getComponent());
3738 RowManager.prototype.getDataCount =
function (active) {
3740 var rows = this.getRows(active);
3745 RowManager.prototype._genRemoteRequest =
function () {
3749 options = table.options,
3752 if (table.modExists(
"page")) {
3756 if (options.ajaxSorting) {
3758 var sorters =
self.table.modules.sort.getSort();
3760 sorters.forEach(
function (item) {
3765 params[
self.table.modules.page.paginationDataSentNames.sorters] = sorters;
3770 if (options.ajaxFiltering) {
3772 var filters =
self.table.modules.filter.getFilters(
true,
true);
3774 params[
self.table.modules.page.paginationDataSentNames.filters] = filters;
3777 self.table.modules.ajax.setParams(params,
true);
3780 table.modules.ajax.sendRequest().then(
function (data) {
3783 }).
catch(
function (e) {});
3788 RowManager.prototype.filterRefresh =
function () {
3790 var table = this.table,
3791 options = table.options,
3792 left = this.scrollLeft;
3794 if (options.ajaxFiltering) {
3796 if (options.pagination ==
"remote" && table.modExists(
"page")) {
3798 table.modules.page.reset(
true);
3800 table.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
3801 }
else if (options.ajaxProgressiveLoad) {
3803 table.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
3808 this._genRemoteRequest();
3812 this.refreshActiveData(
"filter");
3815 this.scrollHorizontal(left);
3820 RowManager.prototype.sorterRefresh =
function (loadOrignalData) {
3822 var table = this.table,
3823 options = this.table.options,
3824 left = this.scrollLeft;
3826 if (options.ajaxSorting) {
3828 if ((options.pagination ==
"remote" || options.progressiveLoad) && table.modExists(
"page")) {
3830 table.modules.page.reset(
true);
3832 table.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
3833 }
else if (options.ajaxProgressiveLoad) {
3835 table.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
3840 this._genRemoteRequest();
3844 this.refreshActiveData(loadOrignalData ?
"filter" :
"sort");
3847 this.scrollHorizontal(left);
3850 RowManager.prototype.scrollHorizontal =
function (left) {
3852 this.scrollLeft = left;
3854 this.element.scrollLeft = left;
3856 if (this.table.options.groupBy) {
3858 this.table.modules.groupRows.scrollHeaders(left);
3861 if (this.table.modExists(
"columnCalcs")) {
3863 this.table.modules.columnCalcs.scrollHorizontal(left);
3869 RowManager.prototype.refreshActiveData =
function (stage, skipStage, renderInPosition) {
3874 cascadeOrder = [
"all",
"filter",
"sort",
"display",
"freeze",
"group",
"tree",
"page"],
3877 if (this.redrawBlock) {
3879 if (!this.redrawBlockRestoreConfig || cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage)) {
3881 this.redrawBlockRestoreConfig = {
3885 skipStage: skipStage,
3887 renderInPosition: renderInPosition
3895 if (
self.table.modExists(
"edit")) {
3897 self.table.modules.edit.cancelEdit();
3905 if (table.options.selectable && !table.options.selectablePersistence && table.modExists(
"selectRow")) {
3907 table.modules.selectRow.deselectRows();
3920 if (table.modExists(
"filter")) {
3922 self.setActiveRows(table.modules.filter.filter(
self.rows));
3925 self.setActiveRows(
self.rows.slice(0));
3936 if (table.modExists(
"sort")) {
3938 table.modules.sort.sort(this.activeRows);
3947 if (this.rowNumColumn) {
3949 this.activeRows.forEach(
function (row) {
3951 var cell = row.getCell(_this12.rowNumColumn);
3955 cell._generateContents();
3964 this.resetDisplayRows();
3970 if (this.table.modExists(
"frozenRows")) {
3972 if (table.modules.frozenRows.isFrozen()) {
3974 if (!table.modules.frozenRows.getDisplayIndex()) {
3976 table.modules.frozenRows.setDisplayIndex(this.getNextDisplayIndex());
3979 displayIndex = table.modules.frozenRows.getDisplayIndex();
3981 displayIndex =
self.setDisplayRows(table.modules.frozenRows.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
3983 if (displayIndex !==
true) {
3985 table.modules.frozenRows.setDisplayIndex(displayIndex);
3998 if (table.options.groupBy && table.modExists(
"groupRows")) {
4000 if (!table.modules.groupRows.getDisplayIndex()) {
4002 table.modules.groupRows.setDisplayIndex(this.getNextDisplayIndex());
4005 displayIndex = table.modules.groupRows.getDisplayIndex();
4007 displayIndex =
self.setDisplayRows(table.modules.groupRows.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
4009 if (displayIndex !==
true) {
4011 table.modules.groupRows.setDisplayIndex(displayIndex);
4023 if (table.options.dataTree && table.modExists(
"dataTree")) {
4025 if (!table.modules.dataTree.getDisplayIndex()) {
4027 table.modules.dataTree.setDisplayIndex(this.getNextDisplayIndex());
4030 displayIndex = table.modules.dataTree.getDisplayIndex();
4032 displayIndex =
self.setDisplayRows(table.modules.dataTree.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
4034 if (displayIndex !==
true) {
4036 table.modules.dataTree.setDisplayIndex(displayIndex);
4044 if (table.options.pagination && table.modExists(
"page") && !renderInPosition) {
4046 if (table.modules.page.getMode() ==
"local") {
4048 table.modules.page.reset();
4056 if (table.options.pagination && table.modExists(
"page")) {
4058 if (!table.modules.page.getDisplayIndex()) {
4060 table.modules.page.setDisplayIndex(this.getNextDisplayIndex());
4063 displayIndex = table.modules.page.getDisplayIndex();
4065 if (table.modules.page.getMode() ==
"local") {
4067 table.modules.page.setMaxRows(this.getDisplayRows(displayIndex - 1).length);
4070 displayIndex =
self.setDisplayRows(table.modules.page.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
4072 if (displayIndex !==
true) {
4074 table.modules.page.setDisplayIndex(displayIndex);
4084 if (Tabulator.prototype.helpers.elVisible(
self.element)) {
4086 if (renderInPosition) {
4088 self.reRenderInPosition();
4093 if (table.options.layoutColumnsOnNewData) {
4095 self.table.columnManager.redraw(
true);
4100 if (table.modExists(
"columnCalcs")) {
4102 table.modules.columnCalcs.recalc(this.activeRows);
4107 RowManager.prototype.setActiveRows =
function (activeRows) {
4109 this.activeRows = activeRows;
4111 this.activeRowsCount = this.activeRows.length;
4116 RowManager.prototype.resetDisplayRows =
function () {
4118 this.displayRows = [];
4120 this.displayRows.push(this.activeRows.slice(0));
4122 this.displayRowsCount = this.displayRows[0].length;
4124 if (this.table.modExists(
"frozenRows")) {
4126 this.table.modules.frozenRows.setDisplayIndex(0);
4129 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
4131 this.table.modules.groupRows.setDisplayIndex(0);
4134 if (this.table.options.pagination &&
this.table.modExists(
"page")) {
4136 this.table.modules.page.setDisplayIndex(0);
4140 RowManager.prototype.getNextDisplayIndex =
function () {
4142 return this.displayRows.length;
4147 RowManager.prototype.setDisplayRows =
function (displayRows, index) {
4151 if (index && typeof this.displayRows[index] !=
"undefined") {
4153 this.displayRows[index] = displayRows;
4158 this.displayRows.push(displayRows);
4160 output = index = this.displayRows.length - 1;
4163 if (index == this.displayRows.length - 1) {
4165 this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
4171 RowManager.prototype.getDisplayRows =
function (index) {
4173 if (typeof index ==
"undefined") {
4175 return this.displayRows.length ? this.displayRows[this.displayRows.length - 1] : [];
4178 return this.displayRows[index] || [];
4182 RowManager.prototype.getVisibleRows =
function (viewable) {
4184 var topEdge = this.element.scrollTop,
4185 bottomEdge = this.element.clientHeight + topEdge,
4189 rows = this.getDisplayRows();
4193 this.getDisplayRows();
4195 for (var i = this.vDomTop; i <= this.vDomBottom; i++) {
4201 if (topEdge - rows[i].getElement().offsetTop >= 0) {
4208 if (bottomEdge - rows[i].getElement().offsetTop >= 0) {
4218 if (bottomEdge - rows[i].getElement().offsetTop >= 0) {
4230 topRow = this.vDomTop;
4232 bottomRow = this.vDomBottom;
4235 return rows.slice(topRow, bottomRow + 1);
4240 RowManager.prototype.displayRowIterator =
function (callback) {
4242 this.displayRows.forEach(callback);
4244 this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
4249 RowManager.prototype.getRows =
function (active) {
4257 rows = this.activeRows;
4263 rows = this.getVisibleRows(
true);
4281 RowManager.prototype.reRenderInPosition =
function (callback) {
4283 if (this.getRenderMode() ==
"virtual") {
4285 if (this.redrawBlock) {
4292 this.redrawBlockRederInPosition =
true;
4296 var scrollTop = this.element.scrollTop;
4300 var topOffset =
false;
4302 var left = this.scrollLeft;
4304 var rows = this.getDisplayRows();
4306 for (var i = this.vDomTop; i <= this.vDomBottom; i++) {
4310 var diff = scrollTop - rows[i].getElement().offsetTop;
4312 if (topOffset ===
false || Math.abs(diff) < topOffset) {
4329 this._virtualRenderFill(topRow ===
false ? this.displayRowsCount - 1 : topRow,
true, topOffset || 0);
4331 this.scrollHorizontal(left);
4344 RowManager.prototype.setRenderMode =
function () {
4346 if ((this.table.element.clientHeight ||
this.table.options.height) && this.table.options.virtualDom) {
4348 this.renderMode =
"virtual";
4351 this.renderMode =
"classic";
4355 RowManager.prototype.getRenderMode =
function () {
4357 return this.renderMode;
4360 RowManager.prototype.renderTable =
function () {
4364 self.table.options.renderStarted.call(this.table);
4366 self.element.scrollTop = 0;
4368 switch (
self.renderMode) {
4372 self._simpleRender();
4378 self._virtualRenderFill();
4384 if (
self.firstRender) {
4386 if (
self.displayRowsCount) {
4388 self.firstRender =
false;
4390 self.table.modules.layout.layout();
4393 self.renderEmptyScroll();
4397 if (
self.table.modExists(
"frozenColumns")) {
4399 self.table.modules.frozenColumns.layout();
4402 if (!
self.displayRowsCount) {
4404 if (
self.table.options.placeholder) {
4406 if (this.renderMode) {
4408 self.table.options.placeholder.setAttribute(
"tabulator-render-mode", this.renderMode);
4411 self.getElement().appendChild(
self.table.options.placeholder);
4415 self.table.options.renderComplete.call(this.table);
4420 RowManager.prototype._simpleRender =
function () {
4422 this._clearVirtualDom();
4424 if (this.displayRowsCount) {
4426 this.checkClassicModeGroupHeaderWidth();
4429 this.renderEmptyScroll();
4433 RowManager.prototype.checkClassicModeGroupHeaderWidth =
function () {
4436 element = this.tableElement,
4437 onlyGroupHeaders =
true;
4439 self.getDisplayRows().forEach(
function (row, index) {
4441 self.styleRow(row, index);
4443 element.appendChild(row.getElement());
4445 row.initialize(
true);
4447 if (row.type !==
"group") {
4449 onlyGroupHeaders =
false;
4453 if (onlyGroupHeaders) {
4455 element.style.minWidth =
self.table.columnManager.getWidth() +
"px";
4458 element.style.minWidth =
"";
4464 RowManager.prototype.renderEmptyScroll =
function () {
4466 this.tableElement.style.minWidth = this.table.columnManager.getWidth() +
"px";
4468 this.tableElement.style.minHeight =
"1px";
4470 this.tableElement.style.visibility =
"hidden";
4473 RowManager.prototype._clearVirtualDom =
function () {
4475 var element = this.tableElement;
4477 if (this.table.options.placeholder &&
this.table.options.placeholder.parentNode) {
4479 this.table.options.placeholder.parentNode.removeChild(this.table.options.placeholder);
4484 while (element.firstChild) {
4485 element.removeChild(element.firstChild);
4486 }element.style.paddingTop =
"";
4488 element.style.paddingBottom =
"";
4490 element.style.minWidth =
"";
4492 element.style.minHeight =
"";
4494 element.style.visibility =
"";
4498 this.scrollLeft = 0;
4502 this.vDomBottom = 0;
4504 this.vDomTopPad = 0;
4506 this.vDomBottomPad = 0;
4509 RowManager.prototype.styleRow =
function (row, index) {
4511 var rowEl = row.getElement();
4515 rowEl.classList.add(
"tabulator-row-even");
4517 rowEl.classList.remove(
"tabulator-row-odd");
4520 rowEl.classList.add(
"tabulator-row-odd");
4522 rowEl.classList.remove(
"tabulator-row-even");
4528 RowManager.prototype._virtualRenderFill =
function (position, forceMove, offset) {
4531 element =
self.tableElement,
4532 holder =
self.element,
4537 onlyGroupHeaders =
true,
4538 rows =
self.getDisplayRows();
4540 position = position || 0;
4542 offset = offset || 0;
4546 self._clearVirtualDom();
4549 while (element.firstChild) {
4550 element.removeChild(element.firstChild);
4553 var heightOccupied = (
self.displayRowsCount - position + 1) *
self.vDomRowHeight;
4555 if (heightOccupied <
self.height) {
4557 position -= Math.ceil((
self.height - heightOccupied) /
self.vDomRowHeight);
4567 topPad = Math.min(Math.max(Math.floor(
self.vDomWindowBuffer /
self.vDomRowHeight),
self.vDomWindowMinMarginRows), position);
4572 if (
self.displayRowsCount && Tabulator.prototype.helpers.elVisible(
self.element)) {
4574 self.vDomTop = position;
4576 self.vDomBottom = position - 1;
4578 while ((rowsHeight <=
self.height +
self.vDomWindowBuffer || i <
self.vDomWindowMinTotalRows) &&
self.vDomBottom <
self.displayRowsCount - 1) {
4580 var index =
self.vDomBottom + 1,
4584 self.styleRow(row, index);
4586 element.appendChild(row.getElement());
4588 if (!row.initialized) {
4590 row.initialize(
true);
4593 if (!row.heightInitialized) {
4595 row.normalizeHeight(
true);
4599 rowHeight = row.getHeight();
4603 topPadHeight += rowHeight;
4606 rowsHeight += rowHeight;
4609 if (rowHeight > this.vDomWindowBuffer) {
4611 this.vDomWindowBuffer = rowHeight * 2;
4614 if (row.type !==
"group") {
4616 onlyGroupHeaders =
false;
4626 this.vDomTopPad = 0;
4630 self.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / i);
4632 self.vDomBottomPad =
self.vDomRowHeight * (
self.displayRowsCount -
self.vDomBottom - 1);
4634 self.vDomScrollHeight = topPadHeight + rowsHeight +
self.vDomBottomPad -
self.height;
4637 self.vDomTopPad = !forceMove ?
self.scrollTop - topPadHeight :
self.vDomRowHeight * this.vDomTop + offset;
4639 self.vDomBottomPad =
self.vDomBottom ==
self.displayRowsCount - 1 ? 0 : Math.max(
self.vDomScrollHeight -
self.vDomTopPad - rowsHeight - topPadHeight, 0);
4642 element.style.paddingTop =
self.vDomTopPad +
"px";
4644 element.style.paddingBottom =
self.vDomBottomPad +
"px";
4648 this.scrollTop =
self.vDomTopPad + topPadHeight + offset - (this.element.scrollWidth > this.element.clientWidth ? this.element.offsetHeight - this.element.clientHeight : 0);
4651 this.scrollTop = Math.min(this.scrollTop, this.element.scrollHeight -
this.height);
4655 if (this.element.scrollWidth >
this.element.offsetWidth && forceMove) {
4657 this.scrollTop += this.element.offsetHeight - this.element.clientHeight;
4660 this.vDomScrollPosTop = this.scrollTop;
4662 this.vDomScrollPosBottom = this.scrollTop;
4664 holder.scrollTop = this.scrollTop;
4666 element.style.minWidth = onlyGroupHeaders ?
self.table.columnManager.getWidth() +
"px" :
"";
4668 if (
self.table.options.groupBy) {
4670 if (
self.table.modules.layout.getMode() !=
"fitDataFill" &&
self.displayRowsCount ==
self.table.modules.groupRows.countGroups()) {
4672 self.tableElement.style.minWidth =
self.table.columnManager.getWidth();
4677 this.renderEmptyScroll();
4683 RowManager.prototype.scrollVertical =
function (dir) {
4685 var topDiff = this.scrollTop - this.vDomScrollPosTop;
4687 var bottomDiff = this.scrollTop - this.vDomScrollPosBottom;
4689 var margin = this.vDomWindowBuffer * 2;
4691 if (-topDiff > margin || bottomDiff > margin) {
4695 var left = this.scrollLeft;
4697 this._virtualRenderFill(Math.floor(
this.element.scrollTop /
this.element.scrollHeight *
this.displayRowsCount));
4699 this.scrollHorizontal(left);
4708 this._addTopRow(-topDiff);
4711 if (bottomDiff < 0) {
4715 if (this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer) {
4717 this._removeBottomRow(-bottomDiff);
4728 if (this.scrollTop > this.vDomWindowBuffer) {
4730 this._removeTopRow(topDiff);
4734 if (bottomDiff >= 0) {
4736 this._addBottomRow(bottomDiff);
4742 RowManager.prototype._addTopRow =
function (topDiff) {
4743 var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
4746 var table = this.tableElement,
4747 rows = this.getDisplayRows();
4751 var index = this.vDomTop - 1,
4752 topRow = rows[index],
4753 topRowHeight = topRow.getHeight() || this.vDomRowHeight;
4757 if (topDiff >= topRowHeight) {
4759 this.styleRow(topRow, index);
4761 table.insertBefore(topRow.getElement(), table.firstChild);
4763 if (!topRow.initialized || !topRow.heightInitialized) {
4765 this.vDomTopNewRows.push(topRow);
4767 if (!topRow.heightInitialized) {
4769 topRow.clearCellHeight();
4773 topRow.initialize();
4775 this.vDomTopPad -= topRowHeight;
4777 if (this.vDomTopPad < 0) {
4779 this.vDomTopPad = index * this.vDomRowHeight;
4784 this.vDomTopPad = 0;
4787 table.style.paddingTop = this.vDomTopPad +
"px";
4789 this.vDomScrollPosTop -= topRowHeight;
4794 topDiff = -(this.scrollTop - this.vDomScrollPosTop);
4796 if (topRow.getHeight() > this.vDomWindowBuffer) {
4798 this.vDomWindowBuffer = topRow.getHeight() * 2;
4801 if (i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (rows[this.vDomTop - 1].getHeight() || this.vDomRowHeight)) {
4803 this._addTopRow(topDiff, i + 1);
4806 this._quickNormalizeRowHeight(this.vDomTopNewRows);
4811 RowManager.prototype._removeTopRow =
function (topDiff) {
4813 var table = this.tableElement,
4814 topRow = this.getDisplayRows()[this.vDomTop],
4815 topRowHeight = topRow.getHeight() || this.vDomRowHeight;
4817 if (topDiff >= topRowHeight) {
4819 var rowEl = topRow.getElement();
4821 rowEl.parentNode.removeChild(rowEl);
4823 this.vDomTopPad += topRowHeight;
4825 table.style.paddingTop = this.vDomTopPad +
"px";
4827 this.vDomScrollPosTop += this.vDomTop ? topRowHeight : topRowHeight + this.vDomWindowBuffer;
4831 topDiff = this.scrollTop - this.vDomScrollPosTop;
4833 this._removeTopRow(topDiff);
4837 RowManager.prototype._addBottomRow =
function (bottomDiff) {
4838 var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
4841 var table = this.tableElement,
4842 rows = this.getDisplayRows();
4844 if (this.vDomBottom < this.displayRowsCount - 1) {
4846 var index = this.vDomBottom + 1,
4847 bottomRow = rows[index],
4848 bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
4852 if (bottomDiff >= bottomRowHeight) {
4854 this.styleRow(bottomRow, index);
4856 table.appendChild(bottomRow.getElement());
4858 if (!bottomRow.initialized || !bottomRow.heightInitialized) {
4860 this.vDomBottomNewRows.push(bottomRow);
4862 if (!bottomRow.heightInitialized) {
4864 bottomRow.clearCellHeight();
4868 bottomRow.initialize();
4870 this.vDomBottomPad -= bottomRowHeight;
4872 if (this.vDomBottomPad < 0 || index == this.displayRowsCount - 1) {
4874 this.vDomBottomPad = 0;
4877 table.style.paddingBottom = this.vDomBottomPad +
"px";
4879 this.vDomScrollPosBottom += bottomRowHeight;
4884 bottomDiff = this.scrollTop - this.vDomScrollPosBottom;
4886 if (bottomRow.getHeight() > this.vDomWindowBuffer) {
4888 this.vDomWindowBuffer = bottomRow.getHeight() * 2;
4891 if (i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount - 1 && bottomDiff >= (rows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)) {
4893 this._addBottomRow(bottomDiff, i + 1);
4896 this._quickNormalizeRowHeight(this.vDomBottomNewRows);
4901 RowManager.prototype._removeBottomRow =
function (bottomDiff) {
4903 var table = this.tableElement,
4904 bottomRow = this.getDisplayRows()[this.vDomBottom],
4905 bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
4907 if (bottomDiff >= bottomRowHeight) {
4909 var rowEl = bottomRow.getElement();
4911 if (rowEl.parentNode) {
4913 rowEl.parentNode.removeChild(rowEl);
4916 this.vDomBottomPad += bottomRowHeight;
4918 if (this.vDomBottomPad < 0) {
4920 this.vDomBottomPad = 0;
4923 table.style.paddingBottom = this.vDomBottomPad +
"px";
4925 this.vDomScrollPosBottom -= bottomRowHeight;
4929 bottomDiff = -(this.scrollTop - this.vDomScrollPosBottom);
4931 this._removeBottomRow(bottomDiff);
4935 RowManager.prototype._quickNormalizeRowHeight =
function (rows) {
4937 rows.forEach(
function (row) {
4942 rows.forEach(
function (row) {
4944 row.setCellHeight();
4952 RowManager.prototype.normalizeHeight =
function () {
4954 this.activeRows.forEach(
function (row) {
4956 row.normalizeHeight();
4962 RowManager.prototype.adjustTableSize =
function () {
4964 if (this.renderMode ===
"virtual") {
4966 this.height = this.element.clientHeight;
4968 this.vDomWindowBuffer = this.table.options.virtualDomBuffer || this.height;
4970 var otherHeight = this.columnManager.getElement().offsetHeight + (this.table.footerManager && !this.table.footerManager.external ? this.table.footerManager.getElement().offsetHeight : 0);
4972 this.element.style.minHeight =
"calc(100% - " + otherHeight +
"px)";
4974 this.element.style.height =
"calc(100% - " + otherHeight +
"px)";
4976 this.element.style.maxHeight =
"calc(100% - " + otherHeight +
"px)";
4982 RowManager.prototype.reinitialize =
function () {
4984 this.rows.forEach(
function (row) {
4992 RowManager.prototype.blockRedraw =
function () {
4994 this.redrawBlock =
true;
4996 this.redrawBlockRestoreConfig =
false;
5001 RowManager.prototype.restoreRedraw =
function () {
5003 this.redrawBlock =
false;
5005 if (this.redrawBlockRestoreConfig) {
5007 this.refreshActiveData(this.redrawBlockRestoreConfig.stage,
this.redrawBlockRestoreConfig.skipStage,
this.redrawBlockRestoreConfig.renderInPosition);
5009 this.redrawBlockRestoreConfig =
false;
5012 if (this.redrawBlockRederInPosition) {
5014 this.reRenderInPosition();
5018 this.redrawBlockRederInPosition =
false;
5023 RowManager.prototype.redraw =
function (force) {
5026 left = this.scrollLeft;
5028 this.adjustTableSize();
5030 this.table.tableWidth = this.table.element.clientWidth;
5034 if (this.renderMode ==
"classic") {
5036 if (this.table.options.groupBy) {
5038 this.refreshActiveData(
"group",
false,
false);
5041 this._simpleRender();
5045 this.reRenderInPosition();
5047 this.scrollHorizontal(left);
5050 if (!this.displayRowsCount) {
5052 if (this.table.options.placeholder) {
5054 this.getElement().appendChild(this.table.options.placeholder);
5063 RowManager.prototype.resetScroll =
function () {
5065 this.element.scrollLeft = 0;
5067 this.element.scrollTop = 0;
5069 if (this.table.browser ===
"ie") {
5071 var
event = document.createEvent(
"Event");
5073 event.initEvent(
"scroll",
false,
true);
5075 this.element.dispatchEvent(event);
5078 this.element.dispatchEvent(
new Event(
'scroll'));
5084 var RowComponent =
function RowComponent(row) {
5089 RowComponent.prototype.getData =
function (transform) {
5091 return this._row.getData(transform);
5094 RowComponent.prototype.getElement =
function () {
5096 return this._row.getElement();
5099 RowComponent.prototype.getCells =
function () {
5103 this._row.getCells().forEach(
function (cell) {
5105 cells.push(cell.getComponent());
5111 RowComponent.prototype.getCell =
function (column) {
5113 var cell = this._row.getCell(column);
5115 return cell ? cell.getComponent() :
false;
5118 RowComponent.prototype.getIndex =
function () {
5120 return this._row.getData(
"data")[this._row.table.options.index];
5123 RowComponent.prototype.getPosition =
function (active) {
5125 return this._row.table.rowManager.getRowPosition(this._row, active);
5128 RowComponent.prototype.delete =
function () {
5130 return this._row.delete();
5133 RowComponent.prototype.scrollTo =
function () {
5135 return this._row.table.rowManager.scrollToRow(this._row);
5138 RowComponent.prototype.pageTo =
function () {
5140 if (this._row.table.modExists(
"page",
true)) {
5142 return this._row.table.modules.page.setPageToRow(this._row);
5146 RowComponent.prototype.move =
function (to, after) {
5148 this._row.moveToRow(to, after);
5151 RowComponent.prototype.update =
function (data) {
5153 return this._row.updateData(data);
5156 RowComponent.prototype.normalizeHeight =
function () {
5158 this._row.normalizeHeight(
true);
5161 RowComponent.prototype.select =
function () {
5163 this._row.table.modules.selectRow.selectRows(this._row);
5166 RowComponent.prototype.deselect =
function () {
5168 this._row.table.modules.selectRow.deselectRows(this._row);
5171 RowComponent.prototype.toggleSelect =
function () {
5173 this._row.table.modules.selectRow.toggleRow(this._row);
5176 RowComponent.prototype.isSelected =
function () {
5178 return this._row.table.modules.selectRow.isRowSelected(this._row);
5181 RowComponent.prototype._getSelf =
function () {
5186 RowComponent.prototype.freeze =
function () {
5188 if (this._row.table.modExists(
"frozenRows",
true)) {
5190 this._row.table.modules.frozenRows.freezeRow(this._row);
5194 RowComponent.prototype.unfreeze =
function () {
5196 if (this._row.table.modExists(
"frozenRows",
true)) {
5198 this._row.table.modules.frozenRows.unfreezeRow(this._row);
5202 RowComponent.prototype.treeCollapse =
function () {
5204 if (this._row.table.modExists(
"dataTree",
true)) {
5206 this._row.table.modules.dataTree.collapseRow(this._row);
5210 RowComponent.prototype.treeExpand =
function () {
5212 if (this._row.table.modExists(
"dataTree",
true)) {
5214 this._row.table.modules.dataTree.expandRow(this._row);
5218 RowComponent.prototype.treeToggle =
function () {
5220 if (this._row.table.modExists(
"dataTree",
true)) {
5222 this._row.table.modules.dataTree.toggleRow(this._row);
5226 RowComponent.prototype.getTreeParent =
function () {
5228 if (this._row.table.modExists(
"dataTree",
true)) {
5230 return this._row.table.modules.dataTree.getTreeParent(this._row);
5236 RowComponent.prototype.getTreeChildren =
function () {
5238 if (this._row.table.modExists(
"dataTree",
true)) {
5240 return this._row.table.modules.dataTree.getTreeChildren(this._row);
5246 RowComponent.prototype.reformat =
function () {
5248 return this._row.reinitialize();
5251 RowComponent.prototype.getGroup =
function () {
5253 return this._row.getGroup().getComponent();
5256 RowComponent.prototype.getTable =
function () {
5258 return this._row.table;
5261 RowComponent.prototype.getNextRow =
function () {
5263 var row = this._row.nextRow();
5265 return row ? row.getComponent() : row;
5268 RowComponent.prototype.getPrevRow =
function () {
5270 var row = this._row.prevRow();
5272 return row ? row.getComponent() : row;
5275 var Row =
function Row(data, parent) {
5276 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
"row";
5279 this.table = parent.table;
5281 this.parent = parent;
5287 this.element = this.createElement();
5295 this.heightStyled =
"";
5297 this.manualHeight =
false;
5299 this.outerHeight = 0;
5301 this.initialized =
false;
5303 this.heightInitialized =
false;
5308 this.generateElement();
5311 Row.prototype.createElement =
function () {
5313 var el = document.createElement(
"div");
5315 el.classList.add(
"tabulator-row");
5317 el.setAttribute(
"role",
"row");
5322 Row.prototype.getElement =
function () {
5324 return this.element;
5327 Row.prototype.detachElement =
function () {
5329 if (this.element && this.element.parentNode) {
5331 this.element.parentNode.removeChild(this.element);
5335 Row.prototype.generateElement =
function () {
5344 if (
self.table.options.selectable !==
false &&
self.table.modExists(
"selectRow")) {
5346 self.table.modules.selectRow.initializeRow(
this);
5351 if (
self.table.options.movableRows !==
false &&
self.table.modExists(
"moveRow")) {
5353 self.table.modules.moveRow.initializeRow(
this);
5358 if (
self.table.options.dataTree !==
false &&
self.table.modExists(
"dataTree")) {
5360 self.table.modules.dataTree.initializeRow(
this);
5365 if (
self.table.options.responsiveLayout ===
"collapse" &&
self.table.modExists(
"responsiveLayout")) {
5367 self.table.modules.responsiveLayout.initializeRow(
this);
5372 if (
self.table.options.rowClick) {
5374 self.element.addEventListener(
"click",
function (e) {
5376 self.table.options.rowClick(e,
self.getComponent());
5380 if (
self.table.options.rowDblClick) {
5382 self.element.addEventListener(
"dblclick",
function (e) {
5384 self.table.options.rowDblClick(e,
self.getComponent());
5388 if (
self.table.options.rowContext) {
5390 self.element.addEventListener(
"contextmenu",
function (e) {
5392 self.table.options.rowContext(e,
self.getComponent());
5398 if (
self.table.options.rowMouseEnter) {
5400 self.element.addEventListener(
"mouseenter",
function (e) {
5402 self.table.options.rowMouseEnter(e,
self.getComponent());
5406 if (
self.table.options.rowMouseLeave) {
5408 self.element.addEventListener(
"mouseleave",
function (e) {
5410 self.table.options.rowMouseLeave(e,
self.getComponent());
5414 if (
self.table.options.rowMouseOver) {
5416 self.element.addEventListener(
"mouseover",
function (e) {
5418 self.table.options.rowMouseOver(e,
self.getComponent());
5422 if (
self.table.options.rowMouseOut) {
5424 self.element.addEventListener(
"mouseout",
function (e) {
5426 self.table.options.rowMouseOut(e,
self.getComponent());
5430 if (
self.table.options.rowMouseMove) {
5432 self.element.addEventListener(
"mousemove",
function (e) {
5434 self.table.options.rowMouseMove(e,
self.getComponent());
5438 if (
self.table.options.rowTap) {
5442 self.element.addEventListener(
"touchstart",
function (e) {
5445 }, { passive:
true });
5447 self.element.addEventListener(
"touchend",
function (e) {
5451 self.table.options.rowTap(e,
self.getComponent());
5458 if (
self.table.options.rowDblTap) {
5462 self.element.addEventListener(
"touchend",
function (e) {
5466 clearTimeout(dblTap);
5470 self.table.options.rowDblTap(e,
self.getComponent());
5473 dblTap = setTimeout(
function () {
5475 clearTimeout(dblTap);
5483 if (
self.table.options.rowTapHold) {
5487 self.element.addEventListener(
"touchstart",
function (e) {
5489 clearTimeout(tapHold);
5491 tapHold = setTimeout(
function () {
5493 clearTimeout(tapHold);
5499 self.table.options.rowTapHold(e,
self.getComponent());
5501 }, { passive:
true });
5503 self.element.addEventListener(
"touchend",
function (e) {
5505 clearTimeout(tapHold);
5512 Row.prototype.generateCells =
function () {
5514 this.cells = this.table.columnManager.generateCells(
this);
5519 Row.prototype.initialize =
function (force) {
5523 if (!
self.initialized || force) {
5527 while (
self.element.firstChild) {
5528 self.element.removeChild(
self.element.firstChild);
5531 if (this.table.modExists(
"frozenColumns")) {
5533 this.table.modules.frozenColumns.layoutRow(
this);
5536 this.generateCells();
5538 self.cells.forEach(
function (cell) {
5540 self.element.appendChild(cell.getElement());
5542 cell.cellRendered();
5547 self.normalizeHeight();
5552 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
5554 self.table.modules.dataTree.layoutRow(
this);
5559 if (
self.table.options.responsiveLayout ===
"collapse" &&
self.table.modExists(
"responsiveLayout")) {
5561 self.table.modules.responsiveLayout.layoutRow(
this);
5564 if (
self.table.options.rowFormatter) {
5566 self.table.options.rowFormatter(
self.getComponent());
5571 if (
self.table.options.resizableRows &&
self.table.modExists(
"resizeRows")) {
5573 self.table.modules.resizeRows.initializeRow(
self);
5576 self.initialized =
true;
5580 Row.prototype.reinitializeHeight =
function () {
5582 this.heightInitialized =
false;
5584 if (this.element.offsetParent !== null) {
5586 this.normalizeHeight(
true);
5590 Row.prototype.reinitialize =
function () {
5592 this.initialized =
false;
5594 this.heightInitialized =
false;
5596 if (!this.manualHeight) {
5600 this.heightStyled =
"";
5603 if (this.element.offsetParent !== null) {
5605 this.initialize(
true);
5611 Row.prototype.calcHeight =
function (force) {
5614 minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
5616 this.cells.forEach(
function (cell) {
5618 var height = cell.getHeight();
5620 if (height > maxHeight) {
5628 this.height = Math.max(maxHeight, minHeight);
5631 this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
5634 this.heightStyled = this.height ? this.height +
"px" :
"";
5636 this.outerHeight = this.element.offsetHeight;
5641 Row.prototype.setCellHeight =
function () {
5643 this.cells.forEach(
function (cell) {
5648 this.heightInitialized =
true;
5651 Row.prototype.clearCellHeight =
function () {
5653 this.cells.forEach(
function (cell) {
5661 Row.prototype.normalizeHeight =
function (force) {
5665 this.clearCellHeight();
5668 this.calcHeight(force);
5670 this.setCellHeight();
5685 Row.prototype.setHeight =
function (height, force) {
5687 if (this.height != height || force) {
5689 this.manualHeight =
true;
5691 this.height = height;
5693 this.heightStyled = height ? height +
"px" :
"";
5695 this.setCellHeight();
5699 this.outerHeight = this.element.offsetHeight;
5705 Row.prototype.getHeight =
function () {
5707 return this.outerHeight;
5712 Row.prototype.getWidth =
function () {
5714 return this.element.offsetWidth;
5720 Row.prototype.deleteCell =
function (cell) {
5722 var index = this.cells.indexOf(cell);
5726 this.cells.splice(index, 1);
5733 Row.prototype.setData =
function (data) {
5735 if (this.table.modExists(
"mutator")) {
5737 data = this.table.modules.mutator.transformRow(data,
"data", data);
5742 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {
5744 this.table.modules.reactiveData.watchRow(
this);
5750 Row.prototype.updateData =
function (data) {
5753 var visible = Tabulator.prototype.helpers.elVisible(this.element),
5756 return new Promise(
function (resolve, reject) {
5758 if (typeof data ===
"string") {
5760 data = JSON.parse(data);
5763 if (_this13.table.options.reactiveData && _this13.table.modExists(
"reactiveData",
true)) {
5765 _this13.table.modules.reactiveData.block();
5770 if (_this13.table.modExists(
"mutator")) {
5772 tempData = Object.assign(tempData, _this13.data);
5774 tempData = Object.assign(tempData, data);
5776 data = _this13.table.modules.mutator.transformRow(tempData,
"data", data);
5781 for (var attrname in data) {
5783 _this13.data[attrname] = data[attrname];
5786 if (_this13.table.options.reactiveData && _this13.table.modExists(
"reactiveData",
true)) {
5788 _this13.table.modules.reactiveData.unblock();
5793 for (var attrname in data) {
5795 var columns = _this13.table.columnManager.getColumnsByFieldRoot(attrname);
5797 columns.forEach(
function (column) {
5799 var cell = _this13.getCell(column.getField());
5803 var value = column.getFieldValue(data);
5805 if (cell.getValue() != value) {
5807 cell.setValueProcessData(value);
5811 cell.cellRendered();
5822 _this13.normalizeHeight();
5824 if (_this13.table.options.rowFormatter) {
5826 _this13.table.options.rowFormatter(_this13.getComponent());
5830 _this13.initialized =
false;
5834 _this13.heightStyled =
"";
5837 if (_this13.table.options.dataTree !==
false && _this13.table.modExists(
"dataTree") && _this13.table.modules.dataTree.redrawNeeded(data)) {
5839 _this13.table.modules.dataTree.initializeRow(_this13);
5841 _this13.table.modules.dataTree.layoutRow(_this13);
5843 _this13.table.rowManager.refreshActiveData(
"tree",
false,
true);
5849 _this13.table.options.rowUpdated.call(_this13.table, _this13.getComponent());
5855 Row.prototype.getData =
function (transform) {
5861 if (
self.table.modExists(
"accessor")) {
5863 return self.table.modules.accessor.transformRow(
self.data, transform);
5871 Row.prototype.getCell =
function (column) {
5875 column = this.table.columnManager.findColumn(column);
5877 match = this.cells.find(
function (cell) {
5879 return cell.column === column;
5885 Row.prototype.getCellIndex =
function (findCell) {
5887 return this.cells.findIndex(
function (cell) {
5889 return cell === findCell;
5893 Row.prototype.findNextEditableCell =
function (index) {
5895 var nextCell =
false;
5897 if (index < this.cells.length - 1) {
5899 for (var i = index + 1; i < this.cells.length; i++) {
5901 var cell = this.cells[i];
5903 if (cell.column.modules.edit && Tabulator.prototype.helpers.elVisible(cell.getElement())) {
5905 var allowEdit =
true;
5907 if (typeof cell.column.modules.edit.check ==
"function") {
5909 allowEdit = cell.column.modules.edit.check(cell.getComponent());
5925 Row.prototype.findPrevEditableCell =
function (index) {
5927 var prevCell =
false;
5931 for (var i = index - 1; i >= 0; i--) {
5933 var cell = this.cells[i],
5936 if (cell.column.modules.edit && Tabulator.prototype.helpers.elVisible(cell.getElement())) {
5938 if (typeof cell.column.modules.edit.check ==
"function") {
5940 allowEdit = cell.column.modules.edit.check(cell.getComponent());
5956 Row.prototype.getCells =
function () {
5961 Row.prototype.nextRow =
function () {
5963 var row = this.table.rowManager.nextDisplayRow(
this,
true);
5965 return row ||
false;
5968 Row.prototype.prevRow =
function () {
5970 var row = this.table.rowManager.prevDisplayRow(
this,
true);
5972 return row ||
false;
5975 Row.prototype.moveToRow =
function (to, before) {
5977 var toRow = this.table.rowManager.findRow(to);
5981 this.table.rowManager.moveRowActual(
this, toRow, !before);
5983 this.table.rowManager.refreshActiveData(
"display",
false,
true);
5986 console.warn(
"Move Error - No matching row found:", to);
5993 Row.prototype.delete =
function () {
5996 return new Promise(
function (resolve, reject) {
6000 if (_this14.table.options.history && _this14.table.modExists(
"history")) {
6002 if (_this14.table.options.groupBy && _this14.table.modExists(
"groupRows")) {
6004 rows = _this14.getGroup().rows;
6006 index = rows.indexOf(_this14);
6010 index = rows[index - 1];
6014 index = _this14.table.rowManager.getRowIndex(_this14);
6018 index = _this14.table.rowManager.rows[index - 1];
6022 _this14.table.modules.history.action(
"rowDelete", _this14, { data: _this14.getData(), pos: !index, index: index });
6025 _this14.deleteActual();
6031 Row.prototype.deleteActual =
function (blockRedraw) {
6033 var index = this.table.rowManager.getRowIndex(
this);
6037 if (this.table.modExists(
"selectRow")) {
6039 this.table.modules.selectRow._deselectRow(
this,
true);
6051 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {}
6057 if (this.modules.group) {
6059 this.modules.group.removeRow(
this);
6062 this.table.rowManager.deleteRow(
this, blockRedraw);
6066 this.initialized =
false;
6068 this.heightInitialized =
false;
6072 if (this.table.modExists(
"columnCalcs")) {
6074 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
6076 this.table.modules.columnCalcs.recalcRowGroup(
this);
6079 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
6084 Row.prototype.deleteCells =
function () {
6086 var cellCount = this.cells.length;
6088 for (var i = 0; i < cellCount; i++) {
6090 this.cells[0].delete();
6094 Row.prototype.wipe =
function () {
6098 while (this.element.firstChild) {
6099 this.element.removeChild(this.element.firstChild);
6100 }this.element =
false;
6104 if (this.element.parentNode) {
6106 this.element.parentNode.removeChild(this.element);
6110 Row.prototype.getGroup =
function () {
6112 return this.modules.group ||
false;
6117 Row.prototype.getComponent =
function () {
6119 return new RowComponent(
this);
6124 var CellComponent =
function CellComponent(cell) {
6129 CellComponent.prototype.getValue =
function () {
6131 return this._cell.getValue();
6134 CellComponent.prototype.getOldValue =
function () {
6136 return this._cell.getOldValue();
6139 CellComponent.prototype.getElement =
function () {
6141 return this._cell.getElement();
6144 CellComponent.prototype.getRow =
function () {
6146 return this._cell.row.getComponent();
6149 CellComponent.prototype.getData =
function () {
6151 return this._cell.row.getData();
6154 CellComponent.prototype.getField =
function () {
6156 return this._cell.column.getField();
6159 CellComponent.prototype.getColumn =
function () {
6161 return this._cell.column.getComponent();
6164 CellComponent.prototype.setValue =
function (value, mutate) {
6166 if (typeof mutate ==
"undefined") {
6171 this._cell.setValue(value, mutate);
6174 CellComponent.prototype.restoreOldValue =
function () {
6176 this._cell.setValueActual(this._cell.getOldValue());
6179 CellComponent.prototype.edit =
function (force) {
6181 return this._cell.edit(force);
6184 CellComponent.prototype.cancelEdit =
function () {
6186 this._cell.cancelEdit();
6189 CellComponent.prototype.nav =
function () {
6191 return this._cell.nav();
6194 CellComponent.prototype.checkHeight =
function () {
6196 this._cell.checkHeight();
6199 CellComponent.prototype.getTable =
function () {
6201 return this._cell.table;
6204 CellComponent.prototype._getSelf =
function () {
6209 var Cell =
function Cell(column, row) {
6211 this.table = column.table;
6213 this.column = column;
6217 this.element = null;
6221 this.oldValue = null;
6229 this.minWidth = null;
6239 Cell.prototype.build =
function () {
6241 this.generateElement();
6245 this._configureCell();
6247 this.setValueActual(this.column.getFieldValue(
this.row.data));
6250 Cell.prototype.generateElement =
function () {
6252 this.element = document.createElement(
'div');
6254 this.element.className =
"tabulator-cell";
6256 this.element.setAttribute(
"role",
"gridcell");
6258 this.element = this.element;
6261 Cell.prototype._configureCell =
function () {
6264 cellEvents =
self.column.cellEvents,
6265 element =
self.element,
6266 field = this.column.getField();
6270 element.style.textAlign =
self.column.hozAlign;
6274 element.setAttribute(
"tabulator-field", field);
6279 if (
self.column.definition.cssClass) {
6281 var classNames =
self.column.definition.cssClass.split(
" ");
6283 classNames.forEach(
function (className) {
6285 element.classList.add(className);
6291 if (this.table.options.tooltipGenerationMode ===
"hover") {
6293 element.addEventListener(
"mouseenter",
function (e) {
6295 self._generateTooltip();
6299 self._bindClickEvents(cellEvents);
6301 self._bindTouchEvents(cellEvents);
6303 self._bindMouseEvents(cellEvents);
6305 if (
self.column.modules.edit) {
6307 self.table.modules.edit.bindEditor(
self);
6310 if (
self.column.definition.rowHandle &&
self.table.options.movableRows !==
false &&
self.table.modExists(
"moveRow")) {
6312 self.table.modules.moveRow.initializeCell(
self);
6317 if (!
self.column.visible) {
6323 Cell.prototype._bindClickEvents =
function (cellEvents) {
6326 element =
self.element;
6330 if (cellEvents.cellClick ||
self.table.options.cellClick) {
6332 element.addEventListener(
"click",
function (e) {
6334 var component =
self.getComponent();
6336 if (cellEvents.cellClick) {
6338 cellEvents.cellClick.call(
self.table, e, component);
6341 if (
self.table.options.cellClick) {
6343 self.table.options.cellClick.call(
self.table, e, component);
6348 if (cellEvents.cellDblClick ||
this.table.options.cellDblClick) {
6350 element.addEventListener(
"dblclick",
function (e) {
6352 var component =
self.getComponent();
6354 if (cellEvents.cellDblClick) {
6356 cellEvents.cellDblClick.call(
self.table, e, component);
6359 if (
self.table.options.cellDblClick) {
6361 self.table.options.cellDblClick.call(
self.table, e, component);
6366 element.addEventListener(
"dblclick",
function (e) {
6372 if (document.selection) {
6375 var range = document.body.createTextRange();
6377 range.moveToElementText(
self.element);
6380 }
else if (window.getSelection) {
6382 var range = document.createRange();
6384 range.selectNode(
self.element);
6386 window.getSelection().removeAllRanges();
6388 window.getSelection().addRange(range);
6394 if (cellEvents.cellContext ||
this.table.options.cellContext) {
6396 element.addEventListener(
"contextmenu",
function (e) {
6398 var component =
self.getComponent();
6400 if (cellEvents.cellContext) {
6402 cellEvents.cellContext.call(
self.table, e, component);
6405 if (
self.table.options.cellContext) {
6407 self.table.options.cellContext.call(
self.table, e, component);
6413 Cell.prototype._bindMouseEvents =
function (cellEvents) {
6416 element =
self.element;
6418 if (cellEvents.cellMouseEnter ||
self.table.options.cellMouseEnter) {
6420 element.addEventListener(
"mouseenter",
function (e) {
6422 var component =
self.getComponent();
6424 if (cellEvents.cellMouseEnter) {
6426 cellEvents.cellMouseEnter.call(
self.table, e, component);
6429 if (
self.table.options.cellMouseEnter) {
6431 self.table.options.cellMouseEnter.call(
self.table, e, component);
6436 if (cellEvents.cellMouseLeave ||
self.table.options.cellMouseLeave) {
6438 element.addEventListener(
"mouseleave",
function (e) {
6440 var component =
self.getComponent();
6442 if (cellEvents.cellMouseLeave) {
6444 cellEvents.cellMouseLeave.call(
self.table, e, component);
6447 if (
self.table.options.cellMouseLeave) {
6449 self.table.options.cellMouseLeave.call(
self.table, e, component);
6454 if (cellEvents.cellMouseOver ||
self.table.options.cellMouseOver) {
6456 element.addEventListener(
"mouseover",
function (e) {
6458 var component =
self.getComponent();
6460 if (cellEvents.cellMouseOver) {
6462 cellEvents.cellMouseOver.call(
self.table, e, component);
6465 if (
self.table.options.cellMouseOver) {
6467 self.table.options.cellMouseOver.call(
self.table, e, component);
6472 if (cellEvents.cellMouseOut ||
self.table.options.cellMouseOut) {
6474 element.addEventListener(
"mouseout",
function (e) {
6476 var component =
self.getComponent();
6478 if (cellEvents.cellMouseOut) {
6480 cellEvents.cellMouseOut.call(
self.table, e, component);
6483 if (
self.table.options.cellMouseOut) {
6485 self.table.options.cellMouseOut.call(
self.table, e, component);
6490 if (cellEvents.cellMouseMove ||
self.table.options.cellMouseMove) {
6492 element.addEventListener(
"mousemove",
function (e) {
6494 var component =
self.getComponent();
6496 if (cellEvents.cellMouseMove) {
6498 cellEvents.cellMouseMove.call(
self.table, e, component);
6501 if (
self.table.options.cellMouseMove) {
6503 self.table.options.cellMouseMove.call(
self.table, e, component);
6509 Cell.prototype._bindTouchEvents =
function (cellEvents) {
6512 element =
self.element,
6517 if (cellEvents.cellTap ||
this.table.options.cellTap) {
6521 element.addEventListener(
"touchstart",
function (e) {
6524 }, { passive:
true });
6526 element.addEventListener(
"touchend",
function (e) {
6530 var component =
self.getComponent();
6532 if (cellEvents.cellTap) {
6534 cellEvents.cellTap.call(
self.table, e, component);
6537 if (
self.table.options.cellTap) {
6539 self.table.options.cellTap.call(
self.table, e, component);
6547 if (cellEvents.cellDblTap ||
this.table.options.cellDblTap) {
6551 element.addEventListener(
"touchend",
function (e) {
6555 clearTimeout(dblTap);
6559 var component =
self.getComponent();
6561 if (cellEvents.cellDblTap) {
6563 cellEvents.cellDblTap.call(
self.table, e, component);
6566 if (
self.table.options.cellDblTap) {
6568 self.table.options.cellDblTap.call(
self.table, e, component);
6572 dblTap = setTimeout(
function () {
6574 clearTimeout(dblTap);
6582 if (cellEvents.cellTapHold ||
this.table.options.cellTapHold) {
6586 element.addEventListener(
"touchstart",
function (e) {
6588 clearTimeout(tapHold);
6590 tapHold = setTimeout(
function () {
6592 clearTimeout(tapHold);
6598 var component =
self.getComponent();
6600 if (cellEvents.cellTapHold) {
6602 cellEvents.cellTapHold.call(
self.table, e, component);
6605 if (
self.table.options.cellTapHold) {
6607 self.table.options.cellTapHold.call(
self.table, e, component);
6610 }, { passive:
true });
6612 element.addEventListener(
"touchend",
function (e) {
6614 clearTimeout(tapHold);
6623 Cell.prototype._generateContents =
function () {
6627 if (this.table.modExists(
"format")) {
6629 val = this.table.modules.format.formatValue(
this);
6632 val = this.element.innerHTML = this.value;
6635 switch (typeof val ===
'undefined' ?
'undefined' : _typeof(val)) {
6639 if (val instanceof Node) {
6643 while (this.element.firstChild) {
6644 this.element.removeChild(this.element.firstChild);
6645 }this.element.appendChild(val);
6648 this.element.innerHTML =
"";
6652 console.warn(
"Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", val);
6662 this.element.innerHTML =
"";
6668 this.element.innerHTML = val;
6673 Cell.prototype.cellRendered =
function () {
6675 if (this.table.modExists(
"format") && this.table.modules.format.cellRendered) {
6677 this.table.modules.format.cellRendered(
this);
6683 Cell.prototype._generateTooltip =
function () {
6685 var tooltip = this.column.tooltip;
6689 if (tooltip ===
true) {
6691 tooltip = this.value;
6692 }
else if (typeof tooltip ==
"function") {
6694 tooltip = tooltip(this.getComponent());
6696 if (tooltip ===
false) {
6702 if (typeof tooltip ===
"undefined") {
6707 this.element.setAttribute(
"title", tooltip);
6710 this.element.setAttribute(
"title",
"");
6716 Cell.prototype.getElement =
function () {
6718 return this.element;
6721 Cell.prototype.getValue =
function () {
6726 Cell.prototype.getOldValue =
function () {
6728 return this.oldValue;
6734 Cell.prototype.setValue =
function (value, mutate) {
6736 var changed = this.setValueProcessData(value, mutate),
6741 if (this.table.options.history &&
this.table.modExists(
"history")) {
6743 this.table.modules.history.action(
"cellEdit",
this, { oldValue: this.oldValue, newValue: this.value });
6746 component = this.getComponent();
6748 if (this.column.cellEvents.cellEdited) {
6750 this.column.cellEvents.cellEdited.call(this.table, component);
6753 this.table.options.cellEdited.call(this.table, component);
6755 this.table.options.dataEdited.call(this.table, this.table.rowManager.getData());
6759 Cell.prototype.setValueProcessData =
function (value, mutate) {
6761 var changed =
false;
6763 if (this.value != value) {
6769 if (this.column.modules.mutate) {
6771 value = this.table.modules.mutator.transformCell(
this, value);
6776 this.setValueActual(value);
6778 if (changed && this.table.modExists(
"columnCalcs")) {
6780 if (this.column.definition.topCalc ||
this.column.definition.bottomCalc) {
6782 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
6784 if (this.table.options.columnCalcs ==
"table" ||
this.table.options.columnCalcs ==
"both") {
6786 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
6789 if (this.table.options.columnCalcs !=
"table") {
6791 this.table.modules.columnCalcs.recalcRowGroup(this.row);
6795 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
6803 Cell.prototype.setValueActual =
function (value) {
6805 this.oldValue = this.value;
6809 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData")) {
6811 this.table.modules.reactiveData.block();
6814 this.column.setFieldValue(this.row.data, value);
6816 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData")) {
6818 this.table.modules.reactiveData.unblock();
6821 this._generateContents();
6823 this._generateTooltip();
6827 if (this.table.options.resizableColumns &&
this.table.modExists(
"resizeColumns")) {
6829 this.table.modules.resizeColumns.initializeColumn(
"cell", this.column, this.element);
6834 if (this.table.modExists(
"frozenColumns")) {
6836 this.table.modules.frozenColumns.layoutElement(this.element, this.column);
6840 Cell.prototype.setWidth =
function () {
6842 this.width = this.column.width;
6844 this.element.style.width = this.column.widthStyled;
6847 Cell.prototype.clearWidth =
function () {
6851 this.element.style.width =
"";
6854 Cell.prototype.getWidth =
function () {
6856 return this.width || this.element.offsetWidth;
6859 Cell.prototype.setMinWidth =
function () {
6861 this.minWidth = this.column.minWidth;
6863 this.element.style.minWidth = this.column.minWidthStyled;
6866 Cell.prototype.checkHeight =
function () {
6870 this.row.reinitializeHeight();
6873 Cell.prototype.clearHeight =
function () {
6875 this.element.style.height =
"";
6880 Cell.prototype.setHeight =
function () {
6882 this.height = this.row.height;
6884 this.element.style.height = this.row.heightStyled;
6887 Cell.prototype.getHeight =
function () {
6889 return this.height || this.element.offsetHeight;
6892 Cell.prototype.show =
function () {
6894 this.element.style.display =
"";
6897 Cell.prototype.hide =
function () {
6899 this.element.style.display =
"none";
6902 Cell.prototype.edit =
function (force) {
6904 if (this.table.modExists(
"edit",
true)) {
6906 return this.table.modules.edit.editCell(
this, force);
6910 Cell.prototype.cancelEdit =
function () {
6912 if (this.table.modExists(
"edit",
true)) {
6914 var editing = this.table.modules.edit.getCurrentCell();
6916 if (editing && editing._getSelf() ===
this) {
6918 this.table.modules.edit.cancelEdit();
6921 console.warn(
"Cancel Editor Error - This cell is not currently being edited ");
6926 Cell.prototype.delete =
function () {
6928 if (!this.table.rowManager.redrawBlock) {
6930 this.element.parentNode.removeChild(this.element);
6933 this.element =
false;
6935 this.column.deleteCell(
this);
6937 this.row.deleteCell(
this);
6945 Cell.prototype.nav =
function () {
6949 index = this.row.getCellIndex(
this);
6953 next:
function next() {
6955 var nextCell = this.right(),
6960 nextRow =
self.table.rowManager.nextDisplayRow(
self.row,
true);
6964 nextCell = nextRow.findNextEditableCell(-1);
6981 prev:
function prev() {
6983 var nextCell = this.left(),
6988 prevRow =
self.table.rowManager.prevDisplayRow(
self.row,
true);
6992 nextCell = prevRow.findPrevEditableCell(prevRow.cells.length);
7009 left:
function left() {
7011 nextCell =
self.row.findPrevEditableCell(index);
7024 right:
function right() {
7026 nextCell =
self.row.findNextEditableCell(index);
7041 var nextRow =
self.table.rowManager.prevDisplayRow(
self.row,
true);
7045 nextRow.cells[index].edit();
7049 down:
function down() {
7051 var nextRow =
self.table.rowManager.nextDisplayRow(
self.row,
true);
7055 nextRow.cells[index].edit();
7062 Cell.prototype.getIndex =
function () {
7064 this.row.getCellIndex(
this);
7069 Cell.prototype.getComponent =
function () {
7071 return new CellComponent(
this);
7074 var FooterManager =
function FooterManager(table) {
7078 this.active =
false;
7080 this.element = this.createElement();
7082 this.external =
false;
7089 FooterManager.prototype.createElement =
function () {
7091 var el = document.createElement(
"div");
7093 el.classList.add(
"tabulator-footer");
7098 FooterManager.prototype._initialize =
function (element) {
7100 if (this.table.options.footerElement) {
7102 switch (_typeof(this.table.options.footerElement)) {
7106 if (this.table.options.footerElement[0] ===
"<") {
7108 this.element.innerHTML = this.table.options.footerElement;
7111 this.external =
true;
7113 this.element = document.querySelector(this.table.options.footerElement);
7120 this.element = this.table.options.footerElement;
7128 FooterManager.prototype.getElement =
function () {
7130 return this.element;
7133 FooterManager.prototype.append =
function (element, parent) {
7135 this.activate(parent);
7137 this.element.appendChild(element);
7139 this.table.rowManager.adjustTableSize();
7142 FooterManager.prototype.prepend =
function (element, parent) {
7144 this.activate(parent);
7146 this.element.insertBefore(element, this.element.firstChild);
7148 this.table.rowManager.adjustTableSize();
7151 FooterManager.prototype.remove =
function (element) {
7153 element.parentNode.removeChild(element);
7158 FooterManager.prototype.deactivate =
function (force) {
7160 if (!this.element.firstChild || force) {
7162 if (!this.external) {
7164 this.element.parentNode.removeChild(this.element);
7167 this.active =
false;
7173 FooterManager.prototype.activate =
function (parent) {
7179 if (!this.external) {
7181 this.table.element.appendChild(this.getElement());
7183 this.table.element.style.display =
'';
7189 this.links.push(parent);
7193 FooterManager.prototype.redraw =
function () {
7195 this.links.forEach(
function (link) {
7197 link.footerRedraw();
7201 var Tabulator =
function Tabulator(element, options) {
7205 this.columnManager = null;
7207 this.rowManager = null;
7209 this.footerManager = null;
7213 this.browserSlow =
false;
7215 this.browserMobile =
false;
7221 this.initializeElement(element);
7223 this.initializeOptions(options || {});
7227 Tabulator.prototype.comms.register(
this);
7232 Tabulator.prototype.defaultOptions = {
7239 layoutColumnsOnNewData:
false,
7244 columnHeaderVertAlign:
"top",
7246 columnVertAlign:
false,
7249 resizableColumns:
true,
7251 resizableRows:
false,
7265 reactiveData:
false,
7268 nestedFieldSeparator:
".",
7273 tooltipsHeader:
false,
7275 tooltipGenerationMode:
"load",
7280 initialFilter:
false,
7282 initialHeaderFilter:
false,
7285 columnHeaderSortMulti:
true,
7288 sortOrderReverse:
false,
7293 headerSortTristate:
false,
7296 footerElement:
false,
7305 tabEndNewRow:
false,
7308 invalidOptionWarnings:
true,
7313 clipboardCopyStyled:
true,
7315 clipboardCopySelector:
"active",
7317 clipboardCopyFormatter:
"table",
7319 clipboardPasteParser:
"table",
7321 clipboardPasteAction:
"insert",
7323 clipboardCopyConfig:
false,
7326 clipboardCopied:
function clipboardCopied() {},
7328 clipboardPasted:
function clipboardPasted() {},
7330 clipboardPasteError:
function clipboardPasteError() {},
7333 downloadDataFormatter:
false,
7335 downloadReady:
function downloadReady(data, blob) {
7339 downloadComplete:
false,
7341 downloadConfig:
false,
7346 dataTreeElementColumn:
false,
7348 dataTreeBranchElement:
true,
7350 dataTreeChildIndent: 9,
7352 dataTreeChildField:
"_children",
7354 dataTreeCollapseElement:
false,
7356 dataTreeExpandElement:
false,
7358 dataTreeStartExpanded:
false,
7360 dataTreeRowExpanded:
function dataTreeRowExpanded() {},
7362 dataTreeRowCollapsed:
function dataTreeRowCollapsed() {},
7367 printFormatter:
false,
7373 printCopyStyle:
true,
7375 printVisibleRows:
true,
7380 addRowPos:
"bottom",
7383 selectable:
"highlight",
7385 selectableRangeMode:
"drag",
7387 selectableRollingSelection:
true,
7389 selectablePersistence:
true,
7391 selectableCheck:
function selectableCheck(data, row) {
7396 headerFilterPlaceholder:
false,
7399 headerVisible:
true,
7411 virtualDomBuffer: 0,
7414 persistentLayout:
false,
7416 persistentSort:
false,
7418 persistentFilter:
false,
7422 persistenceMode:
true,
7424 persistenceReaderFunc:
false,
7426 persistenceWriterFunc:
false,
7431 responsiveLayout:
false,
7433 responsiveLayoutCollapseStartOpen:
true,
7435 responsiveLayoutCollapseUseFormatters:
true,
7437 responsiveLayoutCollapseFormatter:
false,
7442 paginationSize:
false,
7444 paginationInitialPage: 1,
7446 paginationButtonCount: 5,
7448 paginationSizeSelector:
false,
7450 paginationElement:
false,
7452 paginationDataSent: {},
7454 paginationDataReceived: {},
7456 paginationAddRow:
"page",
7461 ajaxURLGenerator:
false,
7467 ajaxContentType:
"form",
7469 ajaxRequestFunc:
false,
7473 ajaxLoaderLoading:
false,
7475 ajaxLoaderError:
false,
7477 ajaxFiltering:
false,
7481 ajaxProgressiveLoad:
false,
7483 ajaxProgressiveLoadDelay: 0,
7485 ajaxProgressiveLoadScrollMargin: 0,
7490 groupStartOpen:
true,
7497 htmlOutputConfig:
false,
7500 movableColumns:
false,
7505 movableRowsConnectedTables:
false,
7507 movableRowsSender:
false,
7509 movableRowsReceiver:
"insert",
7511 movableRowsSendingStart:
function movableRowsSendingStart() {},
7513 movableRowsSent:
function movableRowsSent() {},
7515 movableRowsSentFailed:
function movableRowsSentFailed() {},
7517 movableRowsSendingStop:
function movableRowsSendingStop() {},
7519 movableRowsReceivingStart:
function movableRowsReceivingStart() {},
7521 movableRowsReceived:
function movableRowsReceived() {},
7523 movableRowsReceivedFailed:
function movableRowsReceivedFailed() {},
7525 movableRowsReceivingStop:
function movableRowsReceivingStop() {},
7527 scrollToRowPosition:
"top",
7529 scrollToRowIfVisible:
true,
7531 scrollToColumnPosition:
"left",
7533 scrollToColumnIfVisible:
true,
7535 rowFormatter:
false,
7541 tableBuilding:
function tableBuilding() {},
7543 tableBuilt:
function tableBuilt() {},
7547 renderStarted:
function renderStarted() {},
7549 renderComplete:
function renderComplete() {},
7565 rowMouseEnter:
false,
7567 rowMouseLeave:
false,
7569 rowMouseOver:
false,
7573 rowMouseMove:
false,
7575 rowAdded:
function rowAdded() {},
7577 rowDeleted:
function rowDeleted() {},
7579 rowMoved:
function rowMoved() {},
7581 rowUpdated:
function rowUpdated() {},
7583 rowSelectionChanged:
function rowSelectionChanged() {},
7585 rowSelected:
function rowSelected() {},
7587 rowDeselected:
function rowDeselected() {},
7589 rowResized:
function rowResized() {},
7597 cellDblClick:
false,
7607 cellMouseEnter:
false,
7609 cellMouseLeave:
false,
7611 cellMouseOver:
false,
7613 cellMouseOut:
false,
7615 cellMouseMove:
false,
7617 cellEditing:
function cellEditing() {},
7619 cellEdited:
function cellEdited() {},
7621 cellEditCancelled:
function cellEditCancelled() {},
7627 columnResized:
function columnResized() {},
7629 columnTitleChanged:
function columnTitleChanged() {},
7631 columnVisibilityChanged:
function columnVisibilityChanged() {},
7635 htmlImporting:
function htmlImporting() {},
7637 htmlImported:
function htmlImported() {},
7641 dataLoading:
function dataLoading() {},
7643 dataLoaded:
function dataLoaded() {},
7645 dataEdited:
function dataEdited() {},
7649 ajaxRequesting:
function ajaxRequesting() {},
7651 ajaxResponse:
false,
7653 ajaxError:
function ajaxError() {},
7657 dataFiltering:
false,
7659 dataFiltered:
false,
7663 dataSorting:
function dataSorting() {},
7665 dataSorted:
function dataSorted() {},
7669 groupToggleElement:
"arrow",
7671 groupClosedShowCalcs:
false,
7673 dataGrouping:
function dataGrouping() {},
7677 groupVisibilityChanged:
function groupVisibilityChanged() {},
7681 groupDblClick:
false,
7683 groupContext:
false,
7689 groupTapHold:
false,
7695 pageLoaded:
function pageLoaded() {},
7699 localized:
function localized() {},
7703 validationFailed:
function validationFailed() {},
7707 historyUndo:
function historyUndo() {},
7709 historyRedo:
function historyRedo() {},
7713 scrollHorizontal:
function scrollHorizontal() {},
7715 scrollVertical:
function scrollVertical() {}
7719 Tabulator.prototype.initializeOptions =
function (options) {
7723 if (options.invalidOptionWarnings !==
false) {
7725 for (var key in options) {
7727 if (typeof this.defaultOptions[key] ===
"undefined") {
7729 console.warn(
"Invalid table constructor option:", key);
7736 for (var key in this.defaultOptions) {
7738 if (key in options) {
7740 this.options[key] = options[key];
7743 if (Array.isArray(
this.defaultOptions[key])) {
7745 this.options[key] = [];
7746 }
else if (_typeof(this.defaultOptions[key]) ===
"object") {
7748 this.options[key] = {};
7751 this.options[key] = this.defaultOptions[key];
7757 Tabulator.prototype.initializeElement =
function (element) {
7759 if (typeof HTMLElement !==
"undefined" && element instanceof HTMLElement) {
7761 this.element = element;
7764 }
else if (typeof element ===
"string") {
7766 this.element = document.querySelector(element);
7773 console.error(
"Tabulator Creation Error - no element found matching selector: ", element);
7779 console.error(
"Tabulator Creation Error - Invalid element provided:", element);
7787 Tabulator.prototype._mapDepricatedFunctionality =
function () {
7791 if (this.options.persistentLayout ||
this.options.persistentSort ||
this.options.persistentFilter) {
7793 if (!this.options.persistence) {
7795 this.options.persistence = {};
7799 if (this.options.persistentLayout) {
7801 console.warn(
"persistentLayout option is deprecated, you should now use the persistence option");
7803 if (this.options.persistence !==
true && typeof
this.options.persistence.columns ===
"undefined") {
7805 this.options.persistence.columns =
true;
7809 if (this.options.persistentSort) {
7811 console.warn(
"persistentSort option is deprecated, you should now use the persistence option");
7813 if (this.options.persistence !==
true && typeof
this.options.persistence.sort ===
"undefined") {
7815 this.options.persistence.sort =
true;
7819 if (this.options.persistentFilter) {
7821 console.warn(
"persistentFilter option is deprecated, you should now use the persistence option");
7823 if (this.options.persistence !==
true && typeof
this.options.persistence.filter ===
"undefined") {
7825 this.options.persistence.filter =
true;
7829 if (this.options.columnVertAlign) {
7831 console.warn(
"columnVertAlign option is deprecated, you should now use the columnHeaderVertAlign option");
7833 this.options.columnHeaderVertAlign = this.options.columnVertAlign;
7837 Tabulator.prototype._clearSelection =
function () {
7839 this.element.classList.add(
"tabulator-block-select");
7841 if (window.getSelection) {
7843 if (window.getSelection().empty) {
7846 window.getSelection().empty();
7847 }
else if (window.getSelection().removeAllRanges) {
7850 window.getSelection().removeAllRanges();
7852 }
else if (document.selection) {
7855 document.selection.empty();
7858 this.element.classList.remove(
"tabulator-block-select");
7863 Tabulator.prototype._create =
function () {
7865 this._clearObjectPointers();
7867 this._mapDepricatedFunctionality();
7871 if (this.element.tagName ===
"TABLE") {
7873 if (this.modExists(
"htmlTableImport",
true)) {
7875 this.modules.htmlTableImport.parseTable();
7879 this.columnManager =
new ColumnManager(
this);
7881 this.rowManager =
new RowManager(
this);
7883 this.footerManager =
new FooterManager(
this);
7885 this.columnManager.setRowManager(this.rowManager);
7887 this.rowManager.setColumnManager(this.columnManager);
7889 this._buildElement();
7891 this._loadInitialData();
7896 Tabulator.prototype._clearObjectPointers =
function () {
7898 this.options.columns = this.options.columns.slice(0);
7900 if (!this.options.reactiveData) {
7902 this.options.data = this.options.data.slice(0);
7908 Tabulator.prototype._buildElement =
function () {
7911 var element = this.element,
7913 options = this.options;
7915 options.tableBuilding.call(
this);
7917 element.classList.add(
"tabulator");
7919 element.setAttribute(
"role",
"grid");
7923 while (element.firstChild) {
7924 element.removeChild(element.firstChild);
7927 if (options.height) {
7929 options.height = isNaN(options.height) ? options.height : options.height +
"px";
7931 element.style.height = options.height;
7934 this.columnManager.initialize();
7936 this.rowManager.initialize();
7938 this._detectBrowser();
7940 if (this.modExists(
"layout",
true)) {
7942 mod.layout.initialize(options.layout);
7947 if (options.headerFilterPlaceholder !==
false) {
7949 mod.localize.setHeaderFilterPlaceholder(options.headerFilterPlaceholder);
7952 for (var locale in options.langs) {
7954 mod.localize.installLang(locale, options.langs[locale]);
7957 mod.localize.setLocale(options.locale);
7961 if (typeof options.placeholder ==
"string") {
7963 var el = document.createElement(
"div");
7965 el.classList.add(
"tabulator-placeholder");
7967 var span = document.createElement(
"span");
7969 span.innerHTML = options.placeholder;
7971 el.appendChild(span);
7973 options.placeholder = el;
7978 element.appendChild(this.columnManager.getElement());
7980 element.appendChild(this.rowManager.getElement());
7982 if (options.footerElement) {
7984 this.footerManager.activate();
7987 if (options.persistence &&
this.modExists(
"persistence",
true)) {
7989 mod.persistence.initialize();
7992 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.columns) {
7994 options.columns = mod.persistence.load(
"columns", options.columns);
7997 if (options.movableRows &&
this.modExists(
"moveRow")) {
7999 mod.moveRow.initialize();
8002 if (options.autoColumns &&
this.options.data) {
8004 this.columnManager.generateColumnsFromRowData(this.options.data);
8007 if (this.modExists(
"columnCalcs")) {
8009 mod.columnCalcs.initialize();
8012 this.columnManager.setColumns(options.columns);
8014 if (options.dataTree &&
this.modExists(
"dataTree",
true)) {
8016 mod.dataTree.initialize();
8019 if (this.modExists(
"frozenRows")) {
8021 this.modules.frozenRows.initialize();
8024 if ((options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.sort || options.initialSort) && this.modExists(
"sort",
true)) {
8028 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.sort) {
8030 sorters = mod.persistence.load(
"sort");
8032 if (sorters ===
false && options.initialSort) {
8034 sorters = options.initialSort;
8036 }
else if (options.initialSort) {
8038 sorters = options.initialSort;
8041 mod.sort.setSort(sorters);
8044 if ((options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.filter || options.initialFilter) && this.modExists(
"filter",
true)) {
8048 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.filter) {
8050 filters = mod.persistence.load(
"filter");
8052 if (filters ===
false && options.initialFilter) {
8054 filters = options.initialFilter;
8056 }
else if (options.initialFilter) {
8058 filters = options.initialFilter;
8061 mod.filter.setFilter(filters);
8064 if (options.initialHeaderFilter &&
this.modExists(
"filter",
true)) {
8066 options.initialHeaderFilter.forEach(
function (item) {
8068 var column = _this15.columnManager.findColumn(item.field);
8072 mod.filter.setHeaderFilterValue(column, item.value);
8075 console.warn(
"Column Filter Error - No matching column found:", item.field);
8082 if (this.modExists(
"ajax")) {
8084 mod.ajax.initialize();
8087 if (options.pagination &&
this.modExists(
"page",
true)) {
8089 mod.page.initialize();
8092 if (options.groupBy &&
this.modExists(
"groupRows",
true)) {
8094 mod.groupRows.initialize();
8097 if (this.modExists(
"keybindings")) {
8099 mod.keybindings.initialize();
8102 if (this.modExists(
"selectRow")) {
8104 mod.selectRow.clearSelectionData(
true);
8107 if (options.autoResize &&
this.modExists(
"resizeTable")) {
8109 mod.resizeTable.initialize();
8112 if (this.modExists(
"clipboard")) {
8114 mod.clipboard.initialize();
8117 if (options.printAsHtml &&
this.modExists(
"print")) {
8119 mod.print.initialize();
8122 options.tableBuilt.call(
this);
8125 Tabulator.prototype._loadInitialData =
function () {
8129 if (
self.options.pagination &&
self.modExists(
"page")) {
8131 self.modules.page.reset(
true);
8133 if (
self.options.pagination ==
"local") {
8135 if (
self.options.data.length) {
8137 self.rowManager.setData(
self.options.data);
8140 if ((
self.options.ajaxURL ||
self.options.ajaxURLGenerator) &&
self.modExists(
"ajax")) {
8142 self.modules.ajax.loadData().then(
function () {}).
catch(
function () {
8144 if (
self.options.paginationInitialPage) {
8146 self.modules.page.setPage(
self.options.paginationInitialPage);
8153 self.rowManager.setData(
self.options.data);
8157 if (
self.options.paginationInitialPage) {
8159 self.modules.page.setPage(
self.options.paginationInitialPage);
8163 if (
self.options.ajaxURL) {
8165 self.modules.page.setPage(
self.options.paginationInitialPage).then(
function () {}).
catch(
function () {});
8168 self.rowManager.setData([]);
8173 if (
self.options.data.length) {
8175 self.rowManager.setData(
self.options.data);
8178 if ((
self.options.ajaxURL ||
self.options.ajaxURLGenerator) &&
self.modExists(
"ajax")) {
8180 self.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
8183 self.rowManager.setData(
self.options.data);
8191 Tabulator.prototype.destroy =
function () {
8193 var element = this.element;
8195 Tabulator.prototype.comms.deregister(
this);
8198 if (this.options.reactiveData &&
this.modExists(
"reactiveData",
true)) {
8200 this.modules.reactiveData.unwatchData();
8205 this.rowManager.rows.forEach(
function (row) {
8210 this.rowManager.rows = [];
8212 this.rowManager.activeRows = [];
8214 this.rowManager.displayRows = [];
8218 if (this.options.autoResize &&
this.modExists(
"resizeTable")) {
8220 this.modules.resizeTable.clearBindings();
8223 if (this.modExists(
"keybindings")) {
8225 this.modules.keybindings.clearBindings();
8230 while (element.firstChild) {
8231 element.removeChild(element.firstChild);
8232 }element.classList.remove(
"tabulator");
8235 Tabulator.prototype._detectBrowser =
function () {
8237 var ua = navigator.userAgent || navigator.vendor || window.opera;
8239 if (ua.indexOf(
"Trident") > -1) {
8241 this.browser =
"ie";
8243 this.browserSlow =
true;
8244 }
else if (ua.indexOf(
"Edge") > -1) {
8246 this.browser =
"edge";
8248 this.browserSlow =
true;
8249 }
else if (ua.indexOf(
"Firefox") > -1) {
8251 this.browser =
"firefox";
8253 this.browserSlow =
false;
8256 this.browser =
"other";
8258 this.browserSlow =
false;
8261 this.browserMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(ua) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|
id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(ua.substr(0, 4));
8269 Tabulator.prototype.blockRedraw = function () {
8271 return this.rowManager.blockRedraw();
8276 Tabulator.prototype.restoreRedraw =
function () {
8278 return this.rowManager.restoreRedraw();
8283 Tabulator.prototype.setDataFromLocalFile =
function (extensions) {
8286 return new Promise(
function (resolve, reject) {
8288 var input = document.createElement(
"input");
8290 input.type =
"file";
8292 input.accept = extensions ||
".json,application/json";
8294 input.addEventListener(
"change",
function (e) {
8296 var file = input.files[0],
8297 reader =
new FileReader(),
8300 reader.readAsText(file);
8302 reader.onload =
function (e) {
8306 data = JSON.parse(reader.result);
8309 console.warn(
"File Load Error - File contents is invalid JSON", e);
8316 _this16._setData(data).then(
function (data) {
8319 }).
catch(
function (err) {
8325 reader.onerror =
function (e) {
8327 console.warn(
"File Load Error - Unable to read file");
8339 Tabulator.prototype.setData =
function (data, params, config) {
8341 if (this.modExists(
"ajax")) {
8343 this.modules.ajax.blockActiveRequest();
8346 return this._setData(data, params, config);
8349 Tabulator.prototype._setData =
function (data, params, config, inPosition) {
8353 if (typeof data ===
"string") {
8355 if (data.indexOf(
"{") == 0 || data.indexOf(
"[") == 0) {
8359 return self.rowManager.setData(JSON.parse(data), inPosition);
8362 if (
self.modExists(
"ajax",
true)) {
8366 self.modules.ajax.setParams(params);
8371 self.modules.ajax.setConfig(config);
8374 self.modules.ajax.setUrl(data);
8376 if (
self.options.pagination ==
"remote" &&
self.modExists(
"page",
true)) {
8378 self.modules.page.reset(
true);
8380 return self.modules.page.setPage(1);
8385 return self.modules.ajax.loadData(inPosition);
8395 return self.rowManager.setData(data, inPosition);
8400 if (
self.modExists(
"ajax") && (
self.modules.ajax.getUrl ||
self.options.ajaxURLGenerator)) {
8402 if (
self.options.pagination ==
"remote" &&
self.modExists(
"page",
true)) {
8404 self.modules.page.reset(
true);
8406 return self.modules.page.setPage(1);
8409 return self.modules.ajax.loadData(inPosition);
8415 return self.rowManager.setData([], inPosition);
8423 Tabulator.prototype.clearData =
function () {
8425 if (this.modExists(
"ajax")) {
8427 this.modules.ajax.blockActiveRequest();
8430 this.rowManager.clearData();
8435 Tabulator.prototype.getData =
function (active) {
8437 if (active ===
true) {
8439 console.warn(
"passing a boolean to the getData function is deprecated, you should now pass the string 'active'");
8444 return this.rowManager.getData(active);
8449 Tabulator.prototype.getDataCount =
function (active) {
8451 if (active ===
true) {
8453 console.warn(
"passing a boolean to the getDataCount function is deprecated, you should now pass the string 'active'");
8458 return this.rowManager.getDataCount(active);
8463 Tabulator.prototype.searchRows =
function (field, type, value) {
8465 if (this.modExists(
"filter",
true)) {
8467 return this.modules.filter.search(
"rows", field, type, value);
8473 Tabulator.prototype.searchData =
function (field, type, value) {
8475 if (this.modExists(
"filter",
true)) {
8477 return this.modules.filter.search(
"data", field, type, value);
8483 Tabulator.prototype.getHtml =
function (visible, style, config) {
8485 if (this.modExists(
"htmlTableExport",
true)) {
8487 return this.modules.htmlTableExport.getHtml(visible, style, config);
8493 Tabulator.prototype.print =
function (visible, style, config) {
8495 if (this.modExists(
"print",
true)) {
8497 return this.modules.print.printFullscreen(visible, style, config);
8503 Tabulator.prototype.getAjaxUrl =
function () {
8505 if (this.modExists(
"ajax",
true)) {
8507 return this.modules.ajax.getUrl();
8513 Tabulator.prototype.replaceData =
function (data, params, config) {
8515 if (this.modExists(
"ajax")) {
8517 this.modules.ajax.blockActiveRequest();
8520 return this._setData(data, params, config,
true);
8525 Tabulator.prototype.updateData =
function (data) {
8532 return new Promise(
function (resolve, reject) {
8534 if (_this17.modExists(
"ajax")) {
8536 _this17.modules.ajax.blockActiveRequest();
8539 if (typeof data ===
"string") {
8541 data = JSON.parse(data);
8546 data.forEach(
function (item) {
8548 var row =
self.rowManager.findRow(item[
self.options.index]);
8554 row.updateData(item).then(
function () {
8567 console.warn(
"Update Error - No data provided");
8569 reject(
"Update Error - No data provided");
8574 Tabulator.prototype.addData =
function (data, pos, index) {
8577 return new Promise(
function (resolve, reject) {
8579 if (_this18.modExists(
"ajax")) {
8581 _this18.modules.ajax.blockActiveRequest();
8584 if (typeof data ===
"string") {
8586 data = JSON.parse(data);
8591 _this18.rowManager.addRows(data, pos, index).then(
function (rows) {
8595 rows.forEach(
function (row) {
8597 output.push(row.getComponent());
8604 console.warn(
"Update Error - No data provided");
8606 reject(
"Update Error - No data provided");
8613 Tabulator.prototype.updateOrAddData =
function (data) {
8620 return new Promise(
function (resolve, reject) {
8622 if (_this19.modExists(
"ajax")) {
8624 _this19.modules.ajax.blockActiveRequest();
8627 if (typeof data ===
"string") {
8629 data = JSON.parse(data);
8634 data.forEach(
function (item) {
8636 var row =
self.rowManager.findRow(item[
self.options.index]);
8642 row.updateData(item).then(
function () {
8646 rows.push(row.getComponent());
8655 self.rowManager.addRows(item).then(
function (newRows) {
8659 rows.push(newRows[0].getComponent());
8670 console.warn(
"Update Error - No data provided");
8672 reject(
"Update Error - No data provided");
8679 Tabulator.prototype.getRow =
function (index) {
8681 var row = this.rowManager.findRow(index);
8685 return row.getComponent();
8688 console.warn(
"Find Error - No matching row found:", index);
8696 Tabulator.prototype.getRowFromPosition =
function (position, active) {
8698 var row = this.rowManager.getRowFromPosition(position, active);
8702 return row.getComponent();
8705 console.warn(
"Find Error - No matching row found:", position);
8713 Tabulator.prototype.deleteRow =
function (index) {
8716 return new Promise(
function (resolve, reject) {
8722 function doneCheck() {
8726 if (count == index.length) {
8730 self.rowManager.reRenderInPosition();
8737 if (!Array.isArray(index)) {
8742 index.forEach(
function (item) {
8744 var row = _this20.rowManager.findRow(item,
true);
8748 row.delete().then(
function () {
8753 }).
catch(
function (err) {
8761 console.warn(
"Delete Error - No matching row found:", item);
8763 reject(
"Delete Error - No matching row found");
8773 Tabulator.prototype.addRow =
function (data, pos, index) {
8776 return new Promise(
function (resolve, reject) {
8778 if (typeof data ===
"string") {
8780 data = JSON.parse(data);
8783 _this21.rowManager.addRows(data, pos, index).then(
function (rows) {
8787 if (_this21.modExists(
"columnCalcs")) {
8789 _this21.modules.columnCalcs.recalc(_this21.rowManager.activeRows);
8792 resolve(rows[0].getComponent());
8799 Tabulator.prototype.updateOrAddRow =
function (index, data) {
8802 return new Promise(
function (resolve, reject) {
8804 var row = _this22.rowManager.findRow(index);
8806 if (typeof data ===
"string") {
8808 data = JSON.parse(data);
8813 row.updateData(data).then(
function () {
8817 if (_this22.modExists(
"columnCalcs")) {
8819 _this22.modules.columnCalcs.recalc(_this22.rowManager.activeRows);
8822 resolve(row.getComponent());
8823 }).
catch(
function (err) {
8829 row = _this22.rowManager.addRows(data).then(
function (rows) {
8833 if (_this22.modExists(
"columnCalcs")) {
8835 _this22.modules.columnCalcs.recalc(_this22.rowManager.activeRows);
8838 resolve(rows[0].getComponent());
8839 }).
catch(
function (err) {
8849 Tabulator.prototype.updateRow =
function (index, data) {
8852 return new Promise(
function (resolve, reject) {
8854 var row = _this23.rowManager.findRow(index);
8856 if (typeof data ===
"string") {
8858 data = JSON.parse(data);
8863 row.updateData(data).then(
function () {
8865 resolve(row.getComponent());
8866 }).
catch(
function (err) {
8872 console.warn(
"Update Error - No matching row found:", index);
8874 reject(
"Update Error - No matching row found");
8881 Tabulator.prototype.scrollToRow =
function (index, position, ifVisible) {
8884 return new Promise(
function (resolve, reject) {
8886 var row = _this24.rowManager.findRow(index);
8890 _this24.rowManager.scrollToRow(row, position, ifVisible).then(
function () {
8893 }).
catch(
function (err) {
8899 console.warn(
"Scroll Error - No matching row found:", index);
8901 reject(
"Scroll Error - No matching row found");
8906 Tabulator.prototype.moveRow =
function (from, to, after) {
8908 var fromRow = this.rowManager.findRow(from);
8912 fromRow.moveToRow(to, after);
8915 console.warn(
"Move Error - No matching row found:", from);
8919 Tabulator.prototype.getRows =
function (active) {
8921 if (active ===
true) {
8923 console.warn(
"passing a boolean to the getRows function is deprecated, you should now pass the string 'active'");
8928 return this.rowManager.getComponents(active);
8933 Tabulator.prototype.getRowPosition =
function (index, active) {
8935 var row = this.rowManager.findRow(index);
8939 return this.rowManager.getRowPosition(row, active);
8942 console.warn(
"Position Error - No matching row found:", index);
8950 Tabulator.prototype.copyToClipboard =
function (selector, selectorParams, formatter, formatterParams) {
8952 if (this.modExists(
"clipboard",
true)) {
8954 this.modules.clipboard.copy(selector, selectorParams, formatter, formatterParams);
8961 Tabulator.prototype.setColumns =
function (definition) {
8963 this.columnManager.setColumns(definition);
8966 Tabulator.prototype.getColumns =
function (structured) {
8968 return this.columnManager.getComponents(structured);
8971 Tabulator.prototype.getColumn =
function (field) {
8973 var col = this.columnManager.findColumn(field);
8977 return col.getComponent();
8980 console.warn(
"Find Error - No matching column found:", field);
8986 Tabulator.prototype.getColumnDefinitions =
function () {
8988 return this.columnManager.getDefinitionTree();
8991 Tabulator.prototype.getColumnLayout =
function () {
8993 if (this.modExists(
"persistence",
true)) {
8995 return this.modules.persistence.parseColumns(this.columnManager.getColumns());
8999 Tabulator.prototype.setColumnLayout =
function (layout) {
9001 if (this.modExists(
"persistence",
true)) {
9003 this.columnManager.setColumns(this.modules.persistence.mergeDefinition(
this.options.columns, layout));
9011 Tabulator.prototype.showColumn =
function (field) {
9013 var column = this.columnManager.findColumn(field);
9019 if (this.options.responsiveLayout &&
this.modExists(
"responsiveLayout",
true)) {
9021 this.modules.responsiveLayout.update();
9025 console.warn(
"Column Show Error - No matching column found:", field);
9031 Tabulator.prototype.hideColumn =
function (field) {
9033 var column = this.columnManager.findColumn(field);
9039 if (this.options.responsiveLayout &&
this.modExists(
"responsiveLayout",
true)) {
9041 this.modules.responsiveLayout.update();
9045 console.warn(
"Column Hide Error - No matching column found:", field);
9051 Tabulator.prototype.toggleColumn =
function (field) {
9053 var column = this.columnManager.findColumn(field);
9057 if (column.visible) {
9066 console.warn(
"Column Visibility Toggle Error - No matching column found:", field);
9072 Tabulator.prototype.addColumn =
function (definition, before, field) {
9075 return new Promise(
function (resolve, reject) {
9077 var column = _this25.columnManager.findColumn(field);
9079 _this25.columnManager.addColumn(definition, before, column).then(
function (column) {
9081 resolve(column.getComponent());
9082 }).
catch(
function (err) {
9089 Tabulator.prototype.deleteColumn =
function (field) {
9092 return new Promise(
function (resolve, reject) {
9094 var column = _this26.columnManager.findColumn(field);
9098 column.delete().then(
function () {
9101 }).
catch(
function (err) {
9107 console.warn(
"Column Delete Error - No matching column found:", field);
9114 Tabulator.prototype.updateColumnDefinition =
function (field, definition) {
9117 return new Promise(
function (resolve, reject) {
9119 var column = _this27.columnManager.findColumn(field);
9123 column.updateDefinition().then(
function (col) {
9126 }).
catch(
function (err) {
9132 console.warn(
"Column Update Error - No matching column found:", field);
9139 Tabulator.prototype.moveColumn =
function (from, to, after) {
9141 var fromColumn = this.columnManager.findColumn(from);
9143 var toColumn = this.columnManager.findColumn(to);
9149 this.columnManager.moveColumn(fromColumn, toColumn, after);
9152 console.warn(
"Move Error - No matching column found:", toColumn);
9156 console.warn(
"Move Error - No matching column found:", from);
9162 Tabulator.prototype.scrollToColumn =
function (field, position, ifVisible) {
9165 return new Promise(
function (resolve, reject) {
9167 var column = _this28.columnManager.findColumn(field);
9171 _this28.columnManager.scrollToColumn(column, position, ifVisible).then(
function () {
9174 }).
catch(
function (err) {
9180 console.warn(
"Scroll Error - No matching column found:", field);
9182 reject(
"Scroll Error - No matching column found");
9189 Tabulator.prototype.setLocale =
function (locale) {
9191 this.modules.localize.setLocale(locale);
9194 Tabulator.prototype.getLocale =
function () {
9196 return this.modules.localize.getLocale();
9199 Tabulator.prototype.getLang =
function (locale) {
9201 return this.modules.localize.getLang(locale);
9209 Tabulator.prototype.redraw =
function (force) {
9211 this.columnManager.redraw(force);
9213 this.rowManager.redraw(force);
9216 Tabulator.prototype.setHeight =
function (height) {
9218 if (this.rowManager.renderMode !==
"classic") {
9220 this.options.height = isNaN(height) ? height : height +
"px";
9222 this.element.style.height = this.options.height;
9224 this.rowManager.redraw();
9227 console.warn(
"setHeight function is not available in classic render mode");
9236 Tabulator.prototype.setSort =
function (sortList, dir) {
9238 if (this.modExists(
"sort",
true)) {
9240 this.modules.sort.setSort(sortList, dir);
9242 this.rowManager.sorterRefresh();
9246 Tabulator.prototype.getSorters =
function () {
9248 if (this.modExists(
"sort",
true)) {
9250 return this.modules.sort.getSort();
9254 Tabulator.prototype.clearSort =
function () {
9256 if (this.modExists(
"sort",
true)) {
9258 this.modules.sort.clear();
9260 this.rowManager.sorterRefresh();
9269 Tabulator.prototype.setFilter =
function (field, type, value) {
9271 if (this.modExists(
"filter",
true)) {
9273 this.modules.filter.setFilter(field, type, value);
9275 this.rowManager.filterRefresh();
9281 Tabulator.prototype.addFilter =
function (field, type, value) {
9283 if (this.modExists(
"filter",
true)) {
9285 this.modules.filter.addFilter(field, type, value);
9287 this.rowManager.filterRefresh();
9293 Tabulator.prototype.getFilters =
function (all) {
9295 if (this.modExists(
"filter",
true)) {
9297 return this.modules.filter.getFilters(all);
9301 Tabulator.prototype.setHeaderFilterFocus =
function (field) {
9303 if (this.modExists(
"filter",
true)) {
9305 var column = this.columnManager.findColumn(field);
9309 this.modules.filter.setHeaderFilterFocus(column);
9312 console.warn(
"Column Filter Focus Error - No matching column found:", field);
9319 Tabulator.prototype.setHeaderFilterValue =
function (field, value) {
9321 if (this.modExists(
"filter",
true)) {
9323 var column = this.columnManager.findColumn(field);
9327 this.modules.filter.setHeaderFilterValue(column, value);
9330 console.warn(
"Column Filter Error - No matching column found:", field);
9337 Tabulator.prototype.getHeaderFilters =
function () {
9339 if (this.modExists(
"filter",
true)) {
9341 return this.modules.filter.getHeaderFilters();
9347 Tabulator.prototype.removeFilter =
function (field, type, value) {
9349 if (this.modExists(
"filter",
true)) {
9351 this.modules.filter.removeFilter(field, type, value);
9353 this.rowManager.filterRefresh();
9359 Tabulator.prototype.clearFilter =
function (all) {
9361 if (this.modExists(
"filter",
true)) {
9363 this.modules.filter.clearFilter(all);
9365 this.rowManager.filterRefresh();
9371 Tabulator.prototype.clearHeaderFilter =
function () {
9373 if (this.modExists(
"filter",
true)) {
9375 this.modules.filter.clearHeaderFilter();
9377 this.rowManager.filterRefresh();
9383 Tabulator.prototype.selectRow =
function (rows) {
9385 if (this.modExists(
"selectRow",
true)) {
9387 if (rows ===
true) {
9389 console.warn(
"passing a boolean to the selectRowselectRow function is deprecated, you should now pass the string 'active'");
9394 this.modules.selectRow.selectRows(rows);
9398 Tabulator.prototype.deselectRow =
function (rows) {
9400 if (this.modExists(
"selectRow",
true)) {
9402 this.modules.selectRow.deselectRows(rows);
9406 Tabulator.prototype.toggleSelectRow =
function (row) {
9408 if (this.modExists(
"selectRow",
true)) {
9410 this.modules.selectRow.toggleRow(row);
9414 Tabulator.prototype.getSelectedRows =
function () {
9416 if (this.modExists(
"selectRow",
true)) {
9418 return this.modules.selectRow.getSelectedRows();
9422 Tabulator.prototype.getSelectedData =
function () {
9424 if (this.modExists(
"selectRow",
true)) {
9426 return this.modules.selectRow.getSelectedData();
9433 Tabulator.prototype.setMaxPage =
function (max) {
9435 if (this.options.pagination &&
this.modExists(
"page")) {
9437 this.modules.page.setMaxPage(max);
9444 Tabulator.prototype.setPage =
function (page) {
9446 if (this.options.pagination &&
this.modExists(
"page")) {
9448 return this.modules.page.setPage(page);
9451 return new Promise(
function (resolve, reject) {
9457 Tabulator.prototype.setPageToRow =
function (row) {
9460 return new Promise(
function (resolve, reject) {
9462 if (_this29.options.pagination && _this29.modExists(
"page")) {
9464 row = _this29.rowManager.findRow(row);
9468 _this29.modules.page.setPageToRow(row).then(
function () {
9471 }).
catch(
function () {
9486 Tabulator.prototype.setPageSize =
function (size) {
9488 if (this.options.pagination &&
this.modExists(
"page")) {
9490 this.modules.page.setPageSize(size);
9492 this.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
9499 Tabulator.prototype.getPageSize =
function () {
9501 if (this.options.pagination &&
this.modExists(
"page",
true)) {
9503 return this.modules.page.getPageSize();
9507 Tabulator.prototype.previousPage =
function () {
9509 if (this.options.pagination &&
this.modExists(
"page")) {
9511 this.modules.page.previousPage();
9518 Tabulator.prototype.nextPage =
function () {
9520 if (this.options.pagination &&
this.modExists(
"page")) {
9522 this.modules.page.nextPage();
9529 Tabulator.prototype.getPage =
function () {
9531 if (this.options.pagination &&
this.modExists(
"page")) {
9533 return this.modules.page.getPage();
9540 Tabulator.prototype.getPageMax =
function () {
9542 if (this.options.pagination &&
this.modExists(
"page")) {
9544 return this.modules.page.getPageMax();
9554 Tabulator.prototype.setGroupBy =
function (groups) {
9556 if (this.modExists(
"groupRows",
true)) {
9558 this.options.groupBy = groups;
9560 this.modules.groupRows.initialize();
9562 this.rowManager.refreshActiveData(
"display");
9564 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
9566 this.modules.persistence.save(
"group");
9574 Tabulator.prototype.setGroupStartOpen =
function (values) {
9576 if (this.modExists(
"groupRows",
true)) {
9578 this.options.groupStartOpen = values;
9580 this.modules.groupRows.initialize();
9582 if (this.options.groupBy) {
9584 this.rowManager.refreshActiveData(
"group");
9586 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
9588 this.modules.persistence.save(
"group");
9592 console.warn(
"Grouping Update - cant refresh view, no groups have been set");
9600 Tabulator.prototype.setGroupHeader =
function (values) {
9602 if (this.modExists(
"groupRows",
true)) {
9604 this.options.groupHeader = values;
9606 this.modules.groupRows.initialize();
9608 if (this.options.groupBy) {
9610 this.rowManager.refreshActiveData(
"group");
9612 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
9614 this.modules.persistence.save(
"group");
9618 console.warn(
"Grouping Update - cant refresh view, no groups have been set");
9626 Tabulator.prototype.getGroups =
function (values) {
9628 if (this.modExists(
"groupRows",
true)) {
9630 return this.modules.groupRows.getGroups(
true);
9639 Tabulator.prototype.getGroupedData =
function () {
9641 if (this.modExists(
"groupRows",
true)) {
9643 return this.options.groupBy ? this.modules.groupRows.getGroupedData() : this.getData();
9649 Tabulator.prototype.getCalcResults =
function () {
9651 if (this.modExists(
"columnCalcs",
true)) {
9653 return this.modules.columnCalcs.getResults();
9663 Tabulator.prototype.navigatePrev =
function () {
9667 if (this.modExists(
"edit",
true)) {
9669 cell = this.modules.edit.currentCell;
9673 return cell.nav().prev();
9680 Tabulator.prototype.navigateNext =
function () {
9684 if (this.modExists(
"edit",
true)) {
9686 cell = this.modules.edit.currentCell;
9690 return cell.nav().next();
9697 Tabulator.prototype.navigateLeft =
function () {
9701 if (this.modExists(
"edit",
true)) {
9703 cell = this.modules.edit.currentCell;
9709 return cell.nav().left();
9716 Tabulator.prototype.navigateRight =
function () {
9720 if (this.modExists(
"edit",
true)) {
9722 cell = this.modules.edit.currentCell;
9728 return cell.nav().right();
9735 Tabulator.prototype.navigateUp =
function () {
9739 if (this.modExists(
"edit",
true)) {
9741 cell = this.modules.edit.currentCell;
9747 return cell.nav().up();
9754 Tabulator.prototype.navigateDown =
function () {
9758 if (this.modExists(
"edit",
true)) {
9760 cell = this.modules.edit.currentCell;
9766 return cell.nav().down();
9775 Tabulator.prototype.undo =
function () {
9777 if (this.options.history &&
this.modExists(
"history",
true)) {
9779 return this.modules.history.undo();
9786 Tabulator.prototype.redo =
function () {
9788 if (this.options.history &&
this.modExists(
"history",
true)) {
9790 return this.modules.history.redo();
9797 Tabulator.prototype.getHistoryUndoSize =
function () {
9799 if (this.options.history &&
this.modExists(
"history",
true)) {
9801 return this.modules.history.getHistoryUndoSize();
9808 Tabulator.prototype.getHistoryRedoSize =
function () {
9810 if (this.options.history &&
this.modExists(
"history",
true)) {
9812 return this.modules.history.getHistoryRedoSize();
9822 Tabulator.prototype.download =
function (type, filename, options, active) {
9824 if (this.modExists(
"download",
true)) {
9826 this.modules.download.download(type, filename, options, active);
9830 Tabulator.prototype.downloadToTab =
function (type, filename, options, active) {
9832 if (this.modExists(
"download",
true)) {
9834 this.modules.download.download(type, filename, options, active,
true);
9841 Tabulator.prototype.tableComms =
function (table, module, action, data) {
9843 this.modules.comms.receive(table, module, action, data);
9851 Tabulator.prototype.moduleBindings = {};
9855 Tabulator.prototype.extendModule =
function (name, property, values) {
9857 if (Tabulator.prototype.moduleBindings[name]) {
9859 var source = Tabulator.prototype.moduleBindings[name].prototype[property];
9863 if ((typeof values ===
'undefined' ?
'undefined' : _typeof(values)) ==
"object") {
9865 for (var key in values) {
9867 source[key] = values[key];
9871 console.warn(
"Module Error - Invalid value type, it must be an object");
9875 console.warn(
"Module Error - property does not exist:", property);
9879 console.warn(
"Module Error - module does not exist:", name);
9885 Tabulator.prototype.registerModule =
function (name, module) {
9889 Tabulator.prototype.moduleBindings[name] = module;
9894 Tabulator.prototype.bindModules =
function () {
9898 for (var name in Tabulator.prototype.moduleBindings) {
9900 this.modules[name] =
new Tabulator.prototype.moduleBindings[name](
this);
9906 Tabulator.prototype.modExists =
function (plugin, required) {
9908 if (this.modules[plugin]) {
9915 console.error(
"Tabulator Module Not Installed: " + plugin);
9922 Tabulator.prototype.helpers = {
9924 elVisible:
function elVisible(el) {
9926 return !(el.offsetWidth <= 0 && el.offsetHeight <= 0);
9929 elOffset:
function elOffset(el) {
9931 var box = el.getBoundingClientRect();
9935 top: box.top + window.pageYOffset - document.documentElement.clientTop,
9937 left: box.left + window.pageXOffset - document.documentElement.clientLeft
9942 deepClone:
function deepClone(obj) {
9944 var clone = Array.isArray(obj) ? [] : {};
9946 for (var i in obj) {
9948 if (obj[i] != null && _typeof(obj[i]) ===
"object") {
9950 if (obj[i] instanceof Date) {
9952 clone[i] =
new Date(obj[i]);
9955 clone[i] = this.deepClone(obj[i]);
9968 Tabulator.prototype.comms = {
9972 register:
function register(table) {
9974 Tabulator.prototype.comms.tables.push(table);
9977 deregister:
function deregister(table) {
9979 var index = Tabulator.prototype.comms.tables.indexOf(table);
9983 Tabulator.prototype.comms.tables.splice(index, 1);
9987 lookupTable:
function lookupTable(query, silent) {
9993 if (typeof query ===
"string") {
9995 matches = document.querySelectorAll(query);
9997 if (matches.length) {
9999 for (var i = 0; i < matches.length; i++) {
10001 match = Tabulator.prototype.comms.matchElement(matches[i]);
10005 results.push(match);
10009 }
else if (typeof HTMLElement !==
"undefined" && query instanceof HTMLElement || query instanceof Tabulator) {
10011 match = Tabulator.prototype.comms.matchElement(query);
10015 results.push(match);
10017 }
else if (Array.isArray(query)) {
10019 query.forEach(
function (item) {
10021 results = results.concat(Tabulator.prototype.comms.lookupTable(item));
10027 console.warn(
"Table Connection Error - Invalid Selector", query);
10034 matchElement:
function matchElement(element) {
10036 return Tabulator.prototype.comms.tables.find(
function (table) {
10038 return element instanceof Tabulator ? table === element : table.element === element;
10044 Tabulator.prototype.findTable =
function (query) {
10046 var results = Tabulator.prototype.comms.lookupTable(query,
true);
10048 return Array.isArray(results) && !results.length ?
false : results;
10051 var Layout =
function Layout(table) {
10053 this.table = table;
10061 Layout.prototype.initialize =
function (layout) {
10063 if (this.modes[layout]) {
10065 this.mode = layout;
10068 console.warn(
"Layout Error - invalid mode set, defaulting to 'fitData' : " + layout);
10070 this.mode =
'fitData';
10073 this.table.element.setAttribute(
"tabulator-layout", this.mode);
10076 Layout.prototype.getMode =
function () {
10084 Layout.prototype.layout =
function () {
10086 this.modes[this.mode].call(
this, this.table.columnManager.columnsByIndex);
10092 Layout.prototype.modes = {
10097 "fitData":
function fitData(columns) {
10099 columns.forEach(
function (column) {
10101 column.reinitializeWidth();
10104 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
10106 this.table.modules.responsiveLayout.update();
10113 "fitDataFill":
function fitDataFill(columns) {
10115 columns.forEach(
function (column) {
10117 column.reinitializeWidth();
10120 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
10122 this.table.modules.responsiveLayout.update();
10129 "fitDataStretch":
function fitDataStretch(columns) {
10130 var _this30 =
this;
10133 tableWidth = this.table.rowManager.element.clientWidth,
10137 columns.forEach(
function (column, i) {
10139 if (!column.widthFixed) {
10141 column.reinitializeWidth();
10144 if (_this30.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible) {
10149 if (column.visible) {
10151 colsWidth += column.getWidth();
10157 gap = tableWidth - colsWidth + lastCol.getWidth();
10159 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
10161 lastCol.setWidth(0);
10163 this.table.modules.responsiveLayout.update();
10168 lastCol.setWidth(gap);
10171 lastCol.reinitializeWidth();
10175 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
10177 this.table.modules.responsiveLayout.update();
10185 "fitColumns":
function fitColumns(columns) {
10189 var totalWidth =
self.table.element.clientWidth;
10192 var fixedWidth = 0;
10198 var flexGrowUnits = 0;
10201 var flexColWidth = 0;
10204 var flexColumns = [];
10207 var fixedShrinkColumns = [];
10210 var flexShrinkUnits = 0;
10213 var overflowWidth = 0;
10219 function calcWidth(width) {
10223 if (typeof width ==
"string") {
10225 if (width.indexOf(
"%") > -1) {
10227 colWidth = totalWidth / 100 * parseInt(width);
10230 colWidth = parseInt(width);
10243 function scaleColumns(columns, freeSpace, colWidth, shrinkCols) {
10245 var oversizeCols = [],
10247 remainingSpace = 0,
10251 undersizeCols = [];
10253 function calcGrow(col) {
10255 return colWidth * (col.column.definition.widthGrow || 1);
10258 function calcShrink(col) {
10260 return calcWidth(col.width) - colWidth * (col.column.definition.widthShrink || 0);
10263 columns.forEach(
function (col, i) {
10265 var width = shrinkCols ? calcShrink(col) : calcGrow(col);
10267 if (col.column.minWidth >= width) {
10269 oversizeCols.push(col);
10272 undersizeCols.push(col);
10274 changeUnits += shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1;
10278 if (oversizeCols.length) {
10280 oversizeCols.forEach(
function (col) {
10282 oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;
10284 col.width = col.column.minWidth;
10287 remainingSpace = freeSpace - oversizeSpace;
10289 nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace;
10291 gap = remainingSpace - nextColWidth * changeUnits;
10293 gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
10296 gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace;
10298 undersizeCols.forEach(
function (column) {
10300 column.width = shrinkCols ? calcShrink(column) : calcGrow(column);
10307 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
10309 this.table.modules.responsiveLayout.update();
10315 if (this.table.rowManager.element.scrollHeight >
this.table.rowManager.element.clientHeight) {
10317 totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;
10320 columns.forEach(
function (column) {
10322 var width, minWidth, colWidth;
10324 if (column.visible) {
10326 width = column.definition.width;
10328 minWidth = parseInt(column.minWidth);
10332 colWidth = calcWidth(width);
10334 fixedWidth += colWidth > minWidth ? colWidth : minWidth;
10336 if (column.definition.widthShrink) {
10338 fixedShrinkColumns.push({
10342 width: colWidth > minWidth ? colWidth : minWidth
10346 flexShrinkUnits += column.definition.widthShrink;
10358 flexGrowUnits += column.definition.widthGrow || 1;
10366 flexWidth = totalWidth - fixedWidth;
10371 flexColWidth = Math.floor(flexWidth / flexGrowUnits);
10376 var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth,
false);
10381 if (flexColumns.length && gapFill > 0) {
10383 flexColumns[flexColumns.length - 1].width += +gapFill;
10389 flexColumns.forEach(
function (col) {
10391 flexWidth -= col.width;
10394 overflowWidth = Math.abs(gapFill) + flexWidth;
10399 if (overflowWidth > 0 && flexShrinkUnits) {
10401 gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits),
true);
10407 if (fixedShrinkColumns.length) {
10409 fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill;
10412 flexColumns.forEach(
function (col) {
10414 col.column.setWidth(col.width);
10417 fixedShrinkColumns.forEach(
function (col) {
10419 col.column.setWidth(col.width);
10425 Tabulator.prototype.registerModule(
"layout", Layout);
10427 var Localize =
function Localize(table) {
10429 this.table = table;
10431 this.locale =
"default";
10435 this.bindings = {};
10440 Localize.prototype.setHeaderFilterPlaceholder =
function (placeholder) {
10442 this.langs.default.headerFilters.default = placeholder;
10447 Localize.prototype.setHeaderFilterColumnPlaceholder =
function (column, placeholder) {
10449 this.langs.default.headerFilters.columns[column] = placeholder;
10451 if (this.lang && !this.lang.headerFilters.columns[column]) {
10453 this.lang.headerFilters.columns[column] = placeholder;
10459 Localize.prototype.installLang =
function (locale, lang) {
10461 if (this.langs[locale]) {
10463 this._setLangProp(this.langs[locale], lang);
10466 this.langs[locale] = lang;
10470 Localize.prototype._setLangProp =
function (lang, values) {
10472 for (var key in values) {
10474 if (lang[key] && _typeof(lang[key]) ==
"object") {
10476 this._setLangProp(lang[key], values[key]);
10479 lang[key] = values[key];
10486 Localize.prototype.setLocale =
function (desiredLocale) {
10490 desiredLocale = desiredLocale ||
"default";
10494 function traverseLang(trans, path) {
10496 for (var prop in trans) {
10498 if (_typeof(trans[prop]) ==
"object") {
10505 traverseLang(trans[prop], path[prop]);
10508 path[prop] = trans[prop];
10515 if (desiredLocale ===
true && navigator.language) {
10519 desiredLocale = navigator.language.toLowerCase();
10522 if (desiredLocale) {
10526 if (!
self.langs[desiredLocale]) {
10528 var prefix = desiredLocale.split(
"-")[0];
10530 if (
self.langs[prefix]) {
10532 console.warn(
"Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix);
10534 desiredLocale = prefix;
10537 console.warn(
"Localization Error - Matching locale not found, using default: ", desiredLocale);
10539 desiredLocale =
"default";
10544 self.locale = desiredLocale;
10548 self.lang = Tabulator.prototype.helpers.deepClone(
self.langs.default || {});
10550 if (desiredLocale !=
"default") {
10552 traverseLang(
self.langs[desiredLocale],
self.lang);
10555 self.table.options.localized.call(
self.table,
self.locale,
self.lang);
10557 self._executeBindings();
10562 Localize.prototype.getLocale =
function (locale) {
10564 return self.locale;
10569 Localize.prototype.getLang =
function (locale) {
10571 return locale ? this.langs[locale] : this.lang;
10576 Localize.prototype.getText =
function (path, value) {
10578 var path = value ? path +
"|" + value : path,
10579 pathArray = path.split(
"|"),
10580 text = this._getLangElement(pathArray, this.locale);
10594 Localize.prototype._getLangElement =
function (path, locale) {
10598 var root =
self.lang;
10600 path.forEach(
function (level) {
10606 rootPath = root[level];
10608 if (typeof rootPath !=
"undefined") {
10623 Localize.prototype.bind =
function (path, callback) {
10625 if (!this.bindings[path]) {
10627 this.bindings[path] = [];
10630 this.bindings[path].push(callback);
10632 callback(this.getText(path), this.lang);
10637 Localize.prototype._executeBindings =
function () {
10641 var _loop =
function _loop(path) {
10643 self.bindings[path].forEach(
function (binding) {
10645 binding(
self.getText(path),
self.lang);
10649 for (var path in
self.bindings) {
10656 Localize.prototype.langs = {
10672 "loading":
"Loading",
10680 "page_size":
"Page Size",
10684 "first_title":
"First Page",
10688 "last_title":
"Last Page",
10692 "prev_title":
"Prev Page",
10696 "next_title":
"Next Page"
10702 "default":
"filter column...",
10712 Tabulator.prototype.registerModule(
"localize", Localize);
10714 var Comms =
function Comms(table) {
10716 this.table = table;
10719 Comms.prototype.getConnections =
function (selectors) {
10725 connection = Tabulator.prototype.comms.lookupTable(selectors);
10727 connection.forEach(
function (con) {
10729 if (
self.table !== con) {
10731 connections.push(con);
10735 return connections;
10738 Comms.prototype.send =
function (selectors, module, action, data) {
10741 connections = this.getConnections(selectors);
10743 connections.forEach(
function (connection) {
10745 connection.tableComms(
self.table.element, module, action, data);
10748 if (!connections.length && selectors) {
10750 console.warn(
"Table Connection Error - No tables matching selector found", selectors);
10754 Comms.prototype.receive =
function (table, module, action, data) {
10756 if (this.table.modExists(module)) {
10758 return this.table.modules[module].commsReceived(table, action, data);
10761 console.warn(
"Inter-table Comms Error - no such module:", module);
10765 Tabulator.prototype.registerModule(
"comms", Comms);
10767 var Accessor =
function Accessor(table) {
10768 this.table = table;
10769 this.allowedTypes = [
"",
"data",
"download",
"clipboard"];
10773 Accessor.prototype.initializeColumn =
function (column) {
10778 this.allowedTypes.forEach(
function (type) {
10779 var key =
"accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),
10782 if (column.definition[key]) {
10783 accessor =
self.lookupAccessor(column.definition[key]);
10789 accessor: accessor,
10790 params: column.definition[key +
"Params"] || {}
10797 column.modules.accessor = config;
10799 }, Accessor.prototype.lookupAccessor =
function (value) {
10800 var accessor =
false;
10803 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
10805 if (this.accessors[value]) {
10806 accessor = this.accessors[value];
10808 console.warn(
"Accessor Error - No such accessor found, ignoring: ", value);
10821 Accessor.prototype.transformRow =
function (dataIn, type) {
10823 key =
"accessor" + (type.charAt(0).toUpperCase() + type.slice(1));
10826 var data = Tabulator.prototype.helpers.deepClone(dataIn || {});
10828 self.table.columnManager.traverse(
function (column) {
10829 var value, accessor, params, component;
10831 if (column.modules.accessor) {
10833 accessor = column.modules.accessor[key] || column.modules.accessor.accessor ||
false;
10836 value = column.getFieldValue(data);
10838 if (value !=
"undefined") {
10839 component = column.getComponent();
10840 params = typeof accessor.params ===
"function" ? accessor.params(value, data, type, component) : accessor.params;
10841 column.setFieldValue(data, accessor.accessor(value, data, type, params, component));
10851 Accessor.prototype.accessors = {};
10853 Tabulator.prototype.registerModule(
"accessor", Accessor);
10854 var Ajax =
function Ajax(table) {
10856 this.table = table;
10857 this.config =
false;
10859 this.urlGenerator =
false;
10860 this.params =
false;
10862 this.loaderElement = this.createLoaderElement();
10863 this.msgElement = this.createMsgElement();
10864 this.loadingElement =
false;
10865 this.errorElement =
false;
10866 this.loaderPromise =
false;
10868 this.progressiveLoad =
false;
10869 this.loading =
false;
10871 this.requestOrder = 0;
10875 Ajax.prototype.initialize =
function () {
10878 this.loaderElement.appendChild(this.msgElement);
10880 if (this.table.options.ajaxLoaderLoading) {
10881 if (typeof this.table.options.ajaxLoaderLoading ==
"string") {
10882 template = document.createElement(
'template');
10883 template.innerHTML = this.table.options.ajaxLoaderLoading.trim();
10884 this.loadingElement =
template.content.firstChild;
10886 this.loadingElement = this.table.options.ajaxLoaderLoading;
10890 this.loaderPromise = this.table.options.ajaxRequestFunc || this.defaultLoaderPromise;
10892 this.urlGenerator = this.table.options.ajaxURLGenerator || this.defaultURLGenerator;
10894 if (this.table.options.ajaxLoaderError) {
10895 if (typeof this.table.options.ajaxLoaderError ==
"string") {
10896 template = document.createElement(
'template');
10897 template.innerHTML = this.table.options.ajaxLoaderError.trim();
10898 this.errorElement =
template.content.firstChild;
10900 this.errorElement = this.table.options.ajaxLoaderError;
10904 if (this.table.options.ajaxParams) {
10905 this.setParams(this.table.options.ajaxParams);
10908 if (this.table.options.ajaxConfig) {
10909 this.setConfig(this.table.options.ajaxConfig);
10912 if (this.table.options.ajaxURL) {
10913 this.setUrl(this.table.options.ajaxURL);
10916 if (this.table.options.ajaxProgressiveLoad) {
10917 if (this.table.options.pagination) {
10918 this.progressiveLoad =
false;
10919 console.error(
"Progressive Load Error - Pagination and progressive load cannot be used at the same time");
10921 if (this.table.modExists(
"page")) {
10922 this.progressiveLoad = this.table.options.ajaxProgressiveLoad;
10923 this.table.modules.page.initializeProgressive(this.progressiveLoad);
10925 console.error(
"Pagination plugin is required for progressive ajax loading");
10931 Ajax.prototype.createLoaderElement =
function () {
10932 var el = document.createElement(
"div");
10933 el.classList.add(
"tabulator-loader");
10937 Ajax.prototype.createMsgElement =
function () {
10938 var el = document.createElement(
"div");
10940 el.classList.add(
"tabulator-loader-msg");
10941 el.setAttribute(
"role",
"alert");
10947 Ajax.prototype.setParams =
function (params, update) {
10949 this.params = this.params || {};
10951 for (var key in params) {
10952 this.params[key] = params[key];
10955 this.params = params;
10959 Ajax.prototype.getParams =
function () {
10960 return this.params || {};
10964 Ajax.prototype.setConfig =
function (config) {
10965 this._loadDefaultConfig();
10967 if (typeof config ==
"string") {
10968 this.config.method = config;
10970 for (var key in config) {
10971 this.config[key] = config[key];
10977 Ajax.prototype._loadDefaultConfig =
function (force) {
10979 if (!
self.config || force) {
10984 for (var key in
self.defaultConfig) {
10985 self.config[key] =
self.defaultConfig[key];
10991 Ajax.prototype.setUrl =
function (url) {
10996 Ajax.prototype.getUrl =
function () {
11001 Ajax.prototype.loadData =
function (inPosition) {
11004 if (this.progressiveLoad) {
11005 return this._loadDataProgressive();
11007 return this._loadDataStandard(inPosition);
11011 Ajax.prototype.nextPage =
function (diff) {
11014 if (!this.loading) {
11016 margin = this.table.options.ajaxProgressiveLoadScrollMargin || this.table.rowManager.getElement().clientHeight * 2;
11018 if (diff < margin) {
11019 this.table.modules.page.nextPage().then(
function () {}).
catch(
function () {});
11024 Ajax.prototype.blockActiveRequest =
function () {
11025 this.requestOrder++;
11028 Ajax.prototype._loadDataProgressive =
function () {
11029 this.table.rowManager.setData([]);
11030 return this.table.modules.page.setPage(1);
11033 Ajax.prototype._loadDataStandard =
function (inPosition) {
11034 var _this31 =
this;
11036 return new Promise(
function (resolve, reject) {
11037 _this31.sendRequest(inPosition).then(
function (data) {
11038 _this31.table.rowManager.setData(data, inPosition).then(
function () {
11040 }).
catch(
function (e) {
11043 }).
catch(
function (e) {
11049 Ajax.prototype.generateParamsList =
function (data, prefix) {
11053 prefix = prefix ||
"";
11055 if (Array.isArray(data)) {
11056 data.forEach(
function (item, i) {
11057 output = output.concat(
self.generateParamsList(item, prefix ? prefix +
"[" + i +
"]" : i));
11059 }
else if ((typeof data ===
'undefined' ?
'undefined' : _typeof(data)) ===
"object") {
11060 for (var key in data) {
11061 output = output.concat(
self.generateParamsList(data[key], prefix ? prefix +
"[" + key +
"]" : key));
11064 output.push({ key: prefix, value: data });
11070 Ajax.prototype.serializeParams =
function (params) {
11071 var output = this.generateParamsList(params),
11074 output.forEach(
function (item) {
11075 encoded.push(encodeURIComponent(item.key) +
"=" + encodeURIComponent(item.value));
11078 return encoded.join(
"&");
11082 Ajax.prototype.sendRequest =
function (silent) {
11083 var _this32 =
this;
11091 self.requestOrder++;
11092 requestNo =
self.requestOrder;
11094 self._loadDefaultConfig();
11096 return new Promise(
function (resolve, reject) {
11097 if (
self.table.options.ajaxRequesting.call(_this32.table,
self.url,
self.params) !==
false) {
11099 self.loading =
true;
11105 _this32.loaderPromise(url,
self.config,
self.params).then(
function (data) {
11106 if (requestNo ===
self.requestOrder) {
11107 if (
self.table.options.ajaxResponse) {
11108 data =
self.table.options.ajaxResponse.call(
self.table,
self.url,
self.params, data);
11112 console.warn(
"Ajax Response Blocked - An active ajax request was blocked by an attempt to change table data while the request was being made");
11117 self.loading =
false;
11118 }).
catch(
function (error) {
11119 console.error(
"Ajax Load Error: ", error);
11120 self.table.options.ajaxError.call(
self.table, error);
11124 setTimeout(
function () {
11128 self.loading =
false;
11138 Ajax.prototype.showLoader =
function () {
11139 var shouldLoad = typeof this.table.options.ajaxLoader ===
"function" ? this.table.options.ajaxLoader() : this.table.options.ajaxLoader;
11145 while (this.msgElement.firstChild) {
11146 this.msgElement.removeChild(this.msgElement.firstChild);
11147 }this.msgElement.classList.remove(
"tabulator-error");
11148 this.msgElement.classList.add(
"tabulator-loading");
11150 if (this.loadingElement) {
11151 this.msgElement.appendChild(this.loadingElement);
11153 this.msgElement.innerHTML = this.table.modules.localize.getText(
"ajax|loading");
11156 this.table.element.appendChild(this.loaderElement);
11160 Ajax.prototype.showError =
function () {
11163 while (this.msgElement.firstChild) {
11164 this.msgElement.removeChild(this.msgElement.firstChild);
11165 }this.msgElement.classList.remove(
"tabulator-loading");
11166 this.msgElement.classList.add(
"tabulator-error");
11168 if (this.errorElement) {
11169 this.msgElement.appendChild(this.errorElement);
11171 this.msgElement.innerHTML = this.table.modules.localize.getText(
"ajax|error");
11174 this.table.element.appendChild(this.loaderElement);
11177 Ajax.prototype.hideLoader =
function () {
11178 if (this.loaderElement.parentNode) {
11179 this.loaderElement.parentNode.removeChild(this.loaderElement);
11184 Ajax.prototype.defaultConfig = {
11188 Ajax.prototype.defaultURLGenerator =
function (url, config, params) {
11191 if (params && Object.keys(params).length) {
11192 if (!config.method || config.method.toLowerCase() ==
"get") {
11193 config.method =
"get";
11195 url += (url.includes(
"?") ?
"&" :
"?") + this.serializeParams(params);
11203 Ajax.prototype.defaultLoaderPromise =
function (url, config, params) {
11207 return new Promise(
function (resolve, reject) {
11210 url =
self.urlGenerator(url, config, params);
11213 if (config.method.toUpperCase() !=
"GET") {
11214 contentType = _typeof(
self.table.options.ajaxContentType) ===
"object" ?
self.table.options.ajaxContentType :
self.contentTypeFormatters[
self.table.options.ajaxContentType];
11217 for (var key in contentType.headers) {
11218 if (!config.headers) {
11219 config.headers = {};
11222 if (typeof config.headers[key] ===
"undefined") {
11223 config.headers[key] = contentType.headers[key];
11227 config.body = contentType.body.call(
self, url, config, params);
11229 console.warn(
"Ajax Error - Invalid ajaxContentType value:",
self.table.options.ajaxContentType);
11236 if (typeof config.headers ===
"undefined") {
11237 config.headers = {};
11240 if (typeof config.headers.Accept ===
"undefined") {
11241 config.headers.Accept =
"application/json";
11244 if (typeof config.headers[
"X-Requested-With"] ===
"undefined") {
11245 config.headers[
"X-Requested-With"] =
"XMLHttpRequest";
11248 if (typeof config.mode ===
"undefined") {
11249 config.mode =
"cors";
11252 if (config.mode ==
"cors") {
11254 if (typeof config.headers[
"Access-Control-Allow-Origin"] ===
"undefined") {
11255 config.headers[
"Access-Control-Allow-Origin"] = window.location.origin;
11258 if (typeof config.credentials ===
"undefined") {
11259 config.credentials =
'same-origin';
11262 if (typeof config.credentials ===
"undefined") {
11263 config.credentials =
'include';
11268 fetch(url, config).then(
function (response) {
11270 response.json().then(
function (data) {
11272 }).
catch(
function (error) {
11274 console.warn(
"Ajax Load Error - Invalid JSON returned", error);
11277 console.error(
"Ajax Load Error - Connection Error: " + response.status, response.statusText);
11280 }).
catch(
function (error) {
11281 console.error(
"Ajax Load Error - Connection Error: ", error);
11285 console.warn(
"Ajax Load Error - No URL Set");
11291 Ajax.prototype.contentTypeFormatters = {
11294 'Content-Type':
'application/json'
11296 body:
function body(url, config, params) {
11297 return JSON.stringify(params);
11302 body:
function body(url, config, params) {
11303 var output = this.generateParamsList(params),
11304 form =
new FormData();
11306 output.forEach(
function (item) {
11307 form.append(item.key, item.value);
11315 Tabulator.prototype.registerModule(
"ajax", Ajax);
11317 var ColumnCalcs =
function ColumnCalcs(table) {
11318 this.table = table;
11319 this.topCalcs = [];
11320 this.botCalcs = [];
11321 this.genColumn =
false;
11322 this.topElement = this.createElement();
11323 this.botElement = this.createElement();
11324 this.topRow =
false;
11325 this.botRow =
false;
11326 this.topInitialized =
false;
11327 this.botInitialized =
false;
11332 ColumnCalcs.prototype.createElement =
function () {
11333 var el = document.createElement(
"div");
11334 el.classList.add(
"tabulator-calcs-holder");
11338 ColumnCalcs.prototype.initialize =
function () {
11339 this.genColumn =
new Column({ field:
"value" },
this);
11343 ColumnCalcs.prototype.registerColumnField =
function () {};
11346 ColumnCalcs.prototype.initializeColumn =
function (column) {
11347 var def = column.definition;
11350 topCalcParams: def.topCalcParams || {},
11351 botCalcParams: def.bottomCalcParams || {}
11356 switch (_typeof(def.topCalc)) {
11358 if (this.calculations[def.topCalc]) {
11359 config.topCalc = this.calculations[def.topCalc];
11361 console.warn(
"Column Calc Error - No such calculation found, ignoring: ", def.topCalc);
11366 config.topCalc = def.topCalc;
11371 if (config.topCalc) {
11372 column.modules.columnCalcs = config;
11373 this.topCalcs.push(column);
11375 if (this.table.options.columnCalcs !=
"group") {
11376 this.initializeTopRow();
11381 if (def.bottomCalc) {
11382 switch (_typeof(def.bottomCalc)) {
11384 if (this.calculations[def.bottomCalc]) {
11385 config.botCalc = this.calculations[def.bottomCalc];
11387 console.warn(
"Column Calc Error - No such calculation found, ignoring: ", def.bottomCalc);
11392 config.botCalc = def.bottomCalc;
11397 if (config.botCalc) {
11398 column.modules.columnCalcs = config;
11399 this.botCalcs.push(column);
11401 if (this.table.options.columnCalcs !=
"group") {
11402 this.initializeBottomRow();
11408 ColumnCalcs.prototype.removeCalcs =
function () {
11409 var changed =
false;
11411 if (this.topInitialized) {
11412 this.topInitialized =
false;
11413 this.topElement.parentNode.removeChild(this.topElement);
11417 if (this.botInitialized) {
11418 this.botInitialized =
false;
11419 this.table.footerManager.remove(this.botElement);
11424 this.table.rowManager.adjustTableSize();
11428 ColumnCalcs.prototype.initializeTopRow =
function () {
11429 if (!this.topInitialized) {
11431 this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
11432 this.topInitialized =
true;
11436 ColumnCalcs.prototype.initializeBottomRow =
function () {
11437 if (!this.botInitialized) {
11438 this.table.footerManager.prepend(this.botElement);
11439 this.botInitialized =
true;
11443 ColumnCalcs.prototype.scrollHorizontal =
function (left) {
11445 scrollWidth = this.table.columnManager.getElement().scrollWidth - this.table.element.clientWidth;
11447 if (this.botInitialized) {
11448 this.botRow.getElement().style.marginLeft = -left +
"px";
11452 ColumnCalcs.prototype.recalc =
function (rows) {
11455 if (this.topInitialized || this.botInitialized) {
11456 data = this.rowsToData(rows);
11458 if (this.topInitialized) {
11460 this.topRow.deleteCells();
11463 row = this.generateRow(
"top", this.rowsToData(rows));
11465 while (this.topElement.firstChild) {
11466 this.topElement.removeChild(this.topElement.firstChild);
11467 }this.topElement.appendChild(row.getElement());
11468 row.initialize(
true);
11471 if (this.botInitialized) {
11473 this.botRow.deleteCells();
11476 row = this.generateRow(
"bottom", this.rowsToData(rows));
11478 while (this.botElement.firstChild) {
11479 this.botElement.removeChild(this.botElement.firstChild);
11480 }this.botElement.appendChild(row.getElement());
11481 row.initialize(
true);
11484 this.table.rowManager.adjustTableSize();
11487 if (this.table.modExists(
"frozenColumns")) {
11488 this.table.modules.frozenColumns.layout();
11493 ColumnCalcs.prototype.recalcRowGroup =
function (row) {
11494 this.recalcGroup(this.table.modules.groupRows.getRowGroup(row));
11497 ColumnCalcs.prototype.recalcGroup =
function (group) {
11502 if (group.calcs.bottom) {
11503 data = this.rowsToData(group.rows);
11504 rowData = this.generateRowData(
"bottom", data);
11506 group.calcs.bottom.updateData(rowData);
11507 group.calcs.bottom.reinitialize();
11510 if (group.calcs.top) {
11511 data = this.rowsToData(group.rows);
11512 rowData = this.generateRowData(
"top", data);
11514 group.calcs.top.updateData(rowData);
11515 group.calcs.top.reinitialize();
11522 ColumnCalcs.prototype.generateTopRow =
function (rows) {
11523 return this.generateRow(
"top", this.rowsToData(rows));
11526 ColumnCalcs.prototype.generateBottomRow =
function (rows) {
11527 return this.generateRow(
"bottom", this.rowsToData(rows));
11530 ColumnCalcs.prototype.rowsToData =
function (rows) {
11533 rows.forEach(
function (row) {
11534 data.push(row.getData());
11541 ColumnCalcs.prototype.generateRow =
function (pos, data) {
11543 rowData = this.generateRowData(pos, data),
11546 if (
self.table.modExists(
"mutator")) {
11547 self.table.modules.mutator.disable();
11550 row =
new Row(rowData,
this,
"calc");
11552 if (
self.table.modExists(
"mutator")) {
11553 self.table.modules.mutator.enable();
11556 row.getElement().classList.add(
"tabulator-calcs",
"tabulator-calcs-" + pos);
11558 row.generateCells =
function () {
11562 self.table.columnManager.columnsByIndex.forEach(
function (column) {
11565 self.genColumn.setField(column.getField());
11566 self.genColumn.hozAlign = column.hozAlign;
11568 if (column.definition[pos +
"CalcFormatter"] &&
self.table.modExists(
"format")) {
11570 self.genColumn.modules.format = {
11571 formatter:
self.table.modules.format.getFormatter(column.definition[pos +
"CalcFormatter"]),
11572 params: column.definition[pos +
"CalcFormatterParams"]
11575 self.genColumn.modules.format = {
11576 formatter:
self.table.modules.format.getFormatter(
"plaintext"),
11582 self.genColumn.definition.cssClass = column.definition.cssClass;
11585 var cell =
new Cell(
self.genColumn, row);
11586 cell.column = column;
11589 column.cells.push(cell);
11592 if (!column.visible) {
11597 this.cells = cells;
11604 ColumnCalcs.prototype.generateRowData =
function (pos, data) {
11606 calcs = pos ==
"top" ? this.topCalcs : this.botCalcs,
11607 type = pos ==
"top" ?
"topCalc" :
"botCalc",
11611 calcs.forEach(
function (column) {
11614 if (column.modules.columnCalcs && column.modules.columnCalcs[type]) {
11615 data.forEach(function (item) {
11616 values.push(column.getFieldValue(item));
11619 paramKey = type +
"Params";
11620 params = typeof column.modules.columnCalcs[paramKey] ===
"function" ? column.modules.columnCalcs[paramKey](values, data) : column.modules.columnCalcs[paramKey];
11622 column.setFieldValue(rowData, column.modules.columnCalcs[type](values, data, params));
11629 ColumnCalcs.prototype.hasTopCalcs =
function () {
11630 return !!this.topCalcs.length;
11633 ColumnCalcs.prototype.hasBottomCalcs =
function () {
11634 return !!this.botCalcs.length;
11638 ColumnCalcs.prototype.redraw =
function () {
11640 this.topRow.normalizeHeight(
true);
11643 this.botRow.normalizeHeight(
true);
11648 ColumnCalcs.prototype.getResults =
function () {
11653 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
11654 groups = this.table.modules.groupRows.getGroups(
true);
11656 groups.forEach(
function (group) {
11657 results[group.getKey()] =
self.getGroupResults(group);
11661 top: this.topRow ? this.topRow.getData() : {},
11662 bottom: this.botRow ? this.botRow.getData() : {}
11670 ColumnCalcs.prototype.getGroupResults =
function (group) {
11672 groupObj = group._getSelf(),
11673 subGroups = group.getSubGroups(),
11674 subGroupResults = {},
11677 subGroups.forEach(
function (subgroup) {
11678 subGroupResults[subgroup.getKey()] =
self.getGroupResults(subgroup);
11682 top: groupObj.calcs.top ? groupObj.calcs.top.getData() : {},
11683 bottom: groupObj.calcs.bottom ? groupObj.calcs.bottom.getData() : {},
11684 groups: subGroupResults
11691 ColumnCalcs.prototype.calculations = {
11692 "avg":
function avg(values, data, calcParams) {
11694 precision = typeof calcParams.precision !==
"undefined" ? calcParams.precision : 2;
11696 if (values.length) {
11697 output = values.reduce(
function (sum, value) {
11698 value = Number(value);
11699 return sum + value;
11702 output = output / values.length;
11704 output = precision !==
false ? output.toFixed(precision) : output;
11707 return parseFloat(output).toString();
11709 "max":
function max(values, data, calcParams) {
11711 precision = typeof calcParams.precision !==
"undefined" ? calcParams.precision :
false;
11713 values.forEach(
function (value) {
11715 value = Number(value);
11717 if (value > output || output === null) {
11722 return output !== null ? precision !==
false ? output.toFixed(precision) : output :
"";
11724 "min":
function min(values, data, calcParams) {
11726 precision = typeof calcParams.precision !==
"undefined" ? calcParams.precision :
false;
11728 values.forEach(
function (value) {
11730 value = Number(value);
11732 if (value < output || output === null) {
11737 return output !== null ? precision !==
false ? output.toFixed(precision) : output :
"";
11739 "sum":
function sum(values, data, calcParams) {
11741 precision = typeof calcParams.precision !==
"undefined" ? calcParams.precision :
false;
11743 if (values.length) {
11744 values.forEach(
function (value) {
11745 value = Number(value);
11747 output += !isNaN(value) ? Number(value) : 0;
11751 return precision !==
false ? output.toFixed(precision) : output;
11753 "concat":
function concat(values, data, calcParams) {
11756 if (values.length) {
11757 output = values.reduce(
function (sum, value) {
11758 return String(sum) + String(value);
11764 "count":
function count(values, data, calcParams) {
11767 if (values.length) {
11768 values.forEach(
function (value) {
11779 Tabulator.prototype.registerModule(
"columnCalcs", ColumnCalcs);
11781 var Clipboard =
function Clipboard(table) {
11782 this.table = table;
11784 this.copySelector =
false;
11785 this.copySelectorParams = {};
11786 this.copyFormatter =
false;
11787 this.copyFormatterParams = {};
11788 this.pasteParser =
function () {};
11789 this.pasteAction =
function () {};
11790 this.htmlElement =
false;
11793 this.blocked =
true;
11796 Clipboard.prototype.initialize =
function () {
11799 this.mode = this.table.options.clipboard;
11801 if (this.mode ===
true || this.mode ===
"copy") {
11802 this.table.element.addEventListener(
"copy",
function (e) {
11805 self.processConfig();
11807 if (!
self.blocked) {
11808 e.preventDefault();
11810 data =
self.generateContent();
11812 if (window.clipboardData && window.clipboardData.setData) {
11813 window.clipboardData.setData(
'Text', data);
11814 }
else if (e.clipboardData && e.clipboardData.setData) {
11815 e.clipboardData.setData(
'text/plain', data);
11816 if (
self.htmlElement) {
11817 e.clipboardData.setData(
'text/html',
self.htmlElement.outerHTML);
11819 }
else if (e.originalEvent && e.originalEvent.clipboardData.setData) {
11820 e.originalEvent.clipboardData.setData(
'text/plain', data);
11821 if (
self.htmlElement) {
11822 e.originalEvent.clipboardData.setData(
'text/html',
self.htmlElement.outerHTML);
11826 self.table.options.clipboardCopied.call(this.table, data);
11833 if (this.mode ===
true || this.mode ===
"paste") {
11834 this.table.element.addEventListener(
"paste",
function (e) {
11839 this.setPasteParser(this.table.options.clipboardPasteParser);
11840 this.setPasteAction(this.table.options.clipboardPasteAction);
11843 Clipboard.prototype.processConfig =
function () {
11845 columnHeaders:
"groups",
11850 if (typeof this.table.options.clipboardCopyHeader !==
"undefined") {
11851 config.columnHeaders = this.table.options.clipboardCopyHeader;
11852 console.warn(
"DEPRECATION WARNING - clipboardCopyHeader option has been deprecated, please use the columnHeaders property on the clipboardCopyConfig option");
11855 if (this.table.options.clipboardCopyConfig) {
11856 for (var key in this.table.options.clipboardCopyConfig) {
11857 config[key] = this.table.options.clipboardCopyConfig[key];
11861 if (config.rowGroups &&
this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
11862 this.config.rowGroups =
true;
11865 if (config.columnHeaders) {
11866 if ((config.columnHeaders ===
"groups" || config ===
true) && this.table.columnManager.columns.length != this.table.columnManager.columnsByIndex.length) {
11867 this.config.columnHeaders =
"groups";
11869 this.config.columnHeaders =
"columns";
11872 this.config.columnHeaders =
false;
11875 if (config.columnCalcs &&
this.table.modExists(
"columnCalcs")) {
11876 this.config.columnCalcs =
true;
11880 Clipboard.prototype.reset =
function () {
11881 this.blocked =
false;
11882 this.originalSelectionText =
"";
11885 Clipboard.prototype.setPasteAction =
function (action) {
11887 switch (typeof action ===
'undefined' ?
'undefined' : _typeof(action)) {
11889 this.pasteAction = this.pasteActions[action];
11891 if (!this.pasteAction) {
11892 console.warn(
"Clipboard Error - No such paste action found:", action);
11897 this.pasteAction = action;
11902 Clipboard.prototype.setPasteParser =
function (parser) {
11903 switch (typeof parser ===
'undefined' ?
'undefined' : _typeof(parser)) {
11905 this.pasteParser = this.pasteParsers[parser];
11907 if (!this.pasteParser) {
11908 console.warn(
"Clipboard Error - No such paste parser found:", parser);
11913 this.pasteParser = parser;
11918 Clipboard.prototype.paste =
function (e) {
11919 var data, rowData, rows;
11921 if (this.checkPaseOrigin(e)) {
11923 data = this.getPasteData(e);
11925 rowData = this.pasteParser.call(
this, data);
11928 e.preventDefault();
11930 if (this.table.modExists(
"mutator")) {
11931 rowData = this.mutateData(rowData);
11934 rows = this.pasteAction.call(
this, rowData);
11935 this.table.options.clipboardPasted.call(this.table, data, rowData, rows);
11937 this.table.options.clipboardPasteError.call(this.table, data);
11942 Clipboard.prototype.mutateData =
function (data) {
11946 if (Array.isArray(data)) {
11947 data.forEach(
function (row) {
11948 output.push(
self.table.modules.mutator.transformRow(row,
"clipboard"));
11957 Clipboard.prototype.checkPaseOrigin =
function (e) {
11960 if (e.target.tagName !=
"DIV" ||
this.table.modules.edit.currentCell) {
11967 Clipboard.prototype.getPasteData =
function (e) {
11970 if (window.clipboardData && window.clipboardData.getData) {
11971 data = window.clipboardData.getData(
'Text');
11972 }
else if (e.clipboardData && e.clipboardData.getData) {
11973 data = e.clipboardData.getData(
'text/plain');
11974 }
else if (e.originalEvent && e.originalEvent.clipboardData.getData) {
11975 data = e.originalEvent.clipboardData.getData(
'text/plain');
11981 Clipboard.prototype.copy =
function (selector, selectorParams, formatter, formatterParams,
internal) {
11982 var range, sel, textRange;
11983 this.blocked =
false;
11985 if (this.mode ===
true || this.mode ===
"copy") {
11987 if (typeof window.getSelection !=
"undefined" && typeof document.createRange !=
"undefined") {
11988 range = document.createRange();
11989 range.selectNodeContents(this.table.element);
11990 sel = window.getSelection();
11992 if (sel.toString() &&
internal) {
11993 selector =
"userSelection";
11995 selectorParams = sel.toString();
11998 sel.removeAllRanges();
11999 sel.addRange(range);
12000 }
else if (typeof document.selection !=
"undefined" && typeof document.body.createTextRange !=
"undefined") {
12001 textRange = document.body.createTextRange();
12002 textRange.moveToElementText(this.table.element);
12003 textRange.select();
12006 this.setSelector(selector);
12007 this.copySelectorParams = typeof selectorParams !=
"undefined" && selectorParams != null ? selectorParams : this.config.columnHeaders;
12008 this.setFormatter(formatter);
12009 this.copyFormatterParams = typeof formatterParams !=
"undefined" && formatterParams != null ? formatterParams : {};
12011 document.execCommand(
'copy');
12014 sel.removeAllRanges();
12019 Clipboard.prototype.setSelector =
function (selector) {
12020 selector = selector || this.table.options.clipboardCopySelector;
12022 switch (typeof selector ===
'undefined' ?
'undefined' : _typeof(selector)) {
12024 if (this.copySelectors[selector]) {
12025 this.copySelector = this.copySelectors[selector];
12027 console.warn(
"Clipboard Error - No such selector found:", selector);
12032 this.copySelector = selector;
12037 Clipboard.prototype.setFormatter =
function (formatter) {
12039 formatter = formatter || this.table.options.clipboardCopyFormatter;
12041 switch (typeof formatter ===
'undefined' ?
'undefined' : _typeof(formatter)) {
12043 if (this.copyFormatters[formatter]) {
12044 this.copyFormatter = this.copyFormatters[formatter];
12046 console.warn(
"Clipboard Error - No such formatter found:", formatter);
12051 this.copyFormatter = formatter;
12056 Clipboard.prototype.generateContent =
function () {
12059 this.htmlElement =
false;
12060 data = this.copySelector.call(
this, this.config, this.copySelectorParams);
12062 return this.copyFormatter.call(
this, data, this.config, this.copyFormatterParams);
12065 Clipboard.prototype.generateSimpleHeaders =
function (columns) {
12068 columns.forEach(
function (column) {
12069 headers.push(column.definition.title);
12075 Clipboard.prototype.generateColumnGroupHeaders =
function (columns) {
12076 var _this33 =
this;
12080 this.table.columnManager.columns.forEach(
function (column) {
12081 var colData = _this33.processColumnGroup(column);
12084 output.push(colData);
12091 Clipboard.prototype.processColumnGroup =
function (column) {
12092 var _this34 =
this;
12094 var subGroups = column.columns;
12098 title: column.definition.title,
12102 if (subGroups.length) {
12103 groupData.subGroups = [];
12104 groupData.width = 0;
12106 subGroups.forEach(
function (subGroup) {
12107 var subGroupData = _this34.processColumnGroup(subGroup);
12109 if (subGroupData) {
12110 groupData.width += subGroupData.width;
12111 groupData.subGroups.push(subGroupData);
12115 if (!groupData.width) {
12119 if (column.field && (column.definition.clipboard || column.visible && column.definition.clipboard !==
false)) {
12120 groupData.width = 1;
12129 Clipboard.prototype.groupHeadersToRows =
function (columns) {
12133 function parseColumnGroup(column, level) {
12135 if (typeof headers[level] ===
"undefined") {
12136 headers[level] = [];
12139 headers[level].push(column.title);
12141 if (column.subGroups) {
12142 column.subGroups.forEach(
function (subGroup) {
12143 parseColumnGroup(subGroup, level + 1);
12146 padColumnheaders();
12150 function padColumnheaders() {
12153 headers.forEach(
function (title) {
12154 var len = title.length;
12160 headers.forEach(
function (title) {
12161 var len = title.length;
12163 for (var i = len; i < max; i++) {
12170 columns.forEach(
function (column) {
12171 parseColumnGroup(column, 0);
12177 Clipboard.prototype.rowsToData =
function (rows, columns, config, params) {
12180 rows.forEach(
function (row) {
12182 rowData = row instanceof RowComponent ? row.getData(
"clipboard") : row;
12184 columns.forEach(
function (column) {
12185 var value = column.getFieldValue(rowData);
12187 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
12189 value = JSON.stringify(value);
12201 rowArray.push(value);
12204 data.push(rowArray);
12210 Clipboard.prototype.buildComplexRows =
function (config) {
12211 var _this35 =
this;
12214 groups = this.table.modules.groupRows.getGroups();
12216 groups.forEach(
function (group) {
12217 output.push(_this35.processGroupData(group));
12223 Clipboard.prototype.processGroupData =
function (group) {
12224 var _this36 =
this;
12226 var subGroups = group.getSubGroups();
12233 if (subGroups.length) {
12234 groupData.subGroups = [];
12236 subGroups.forEach(
function (subGroup) {
12237 groupData.subGroups.push(_this36.processGroupData(subGroup));
12240 groupData.rows = group.getRows(
true);
12246 Clipboard.prototype.getCalcRow =
function (calcs, columns, selector, pos) {
12247 var calcData = calcs[selector];
12251 calcData = calcData[pos];
12254 if (Object.keys(calcData).length) {
12255 return this.rowsToData([calcData], columns);
12262 Clipboard.prototype.buildOutput =
function (rows, config, params) {
12263 var _this37 =
this;
12268 columnsByIndex = [];
12270 this.table.columnManager.columnsByIndex.forEach(
function (column) {
12271 if (column.definition.clipboard || column.visible && column.definition.clipboard !==
false) {
12272 columnsByIndex.push(column);
12276 if (config.columnHeaders ==
"groups") {
12277 columns = this.generateColumnGroupHeaders(this.table.columnManager.columns);
12278 output = output.concat(this.groupHeadersToRows(columns));
12280 columns = columnsByIndex;
12282 output.push(this.generateSimpleHeaders(columns));
12285 if (this.config.columnCalcs) {
12286 calcs = this.table.getCalcResults();
12290 if (this.table.options.clipboardCopyStyled) {
12291 this.generateHTML(rows, columns, calcs, config, params);
12295 if (config.rowGroups) {
12296 rows.forEach(
function (row) {
12297 output = output.concat(_this37.parseRowGroupData(row, columnsByIndex, config, params, calcs || {}));
12300 if (config.columnCalcs) {
12301 output = output.concat(this.getCalcRow(calcs, columnsByIndex,
"top"));
12304 output = output.concat(this.rowsToData(rows, columnsByIndex, config, params));
12306 if (config.columnCalcs) {
12307 output = output.concat(this.getCalcRow(calcs, columnsByIndex,
"bottom"));
12314 Clipboard.prototype.parseRowGroupData =
function (group, columns, config, params, calcObj) {
12315 var _this38 =
this;
12317 var groupData = [];
12319 groupData.push([group.key]);
12321 if (group.subGroups) {
12322 group.subGroups.forEach(
function (subGroup) {
12323 groupData = groupData.concat(_this38.parseRowGroupData(subGroup, config, params, calcObj[group.key] ? calcObj[group.key].groups || {} : {}));
12326 if (config.columnCalcs) {
12327 groupData = groupData.concat(this.getCalcRow(calcObj, columns, group.key,
"top"));
12330 groupData = groupData.concat(this.rowsToData(group.rows, columns, config, params));
12332 if (config.columnCalcs) {
12333 groupData = groupData.concat(this.getCalcRow(calcObj, columns, group.key,
"bottom"));
12340 Clipboard.prototype.generateHTML =
function (rows, columns, calcs, config, params) {
12355 this.htmlElement = document.createElement(
"table");
12356 self.mapElementStyles(this.table.element,
this.htmlElement, [
"border-top",
"border-left",
"border-right",
"border-bottom"]);
12358 function generateSimpleHeaders() {
12359 var headerEl = document.createElement(
"tr");
12361 columns.forEach(
function (column) {
12362 var columnEl = document.createElement(
"th");
12363 columnEl.innerHTML = column.definition.title;
12365 self.mapElementStyles(column.getElement(), columnEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"background-color",
"color",
"font-weight",
"font-family",
"font-size"]);
12367 headerEl.appendChild(columnEl);
12370 self.mapElementStyles(
self.table.columnManager.getHeadersElement(), headerEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"background-color",
"color",
"font-weight",
"font-family",
"font-size"]);
12372 self.htmlElement.appendChild(document.createElement(
"thead").appendChild(headerEl));
12375 function generateHeaders(headers) {
12377 var headerHolderEl = document.createElement(
"thead");
12379 headers.forEach(
function (columns) {
12380 var headerEl = document.createElement(
"tr");
12382 columns.forEach(
function (column) {
12383 var columnEl = document.createElement(
"th");
12385 if (column.width > 1) {
12386 columnEl.colSpan = column.width;
12389 if (column.height > 1) {
12390 columnEl.rowSpan = column.height;
12393 columnEl.innerHTML = column.title;
12395 self.mapElementStyles(column.element, columnEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"background-color",
"color",
"font-weight",
"font-family",
"font-size"]);
12397 headerEl.appendChild(columnEl);
12400 self.mapElementStyles(
self.table.columnManager.getHeadersElement(), headerEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"background-color",
"color",
"font-weight",
"font-family",
"font-size"]);
12402 headerHolderEl.appendChild(headerEl);
12405 self.htmlElement.appendChild(headerHolderEl);
12408 function parseColumnGroup(column, level) {
12410 var actualColumns = [];
12412 if (typeof headers[level] ===
"undefined") {
12413 headers[level] = [];
12416 headers[level].push({
12417 title: column.title,
12418 width: column.width,
12420 children: !!column.subGroups,
12421 element: column.column.getElement()
12424 if (column.subGroups) {
12425 column.subGroups.forEach(
function (subGroup) {
12426 actualColumns = actualColumns.concat(parseColumnGroup(subGroup, level + 1));
12429 return actualColumns;
12431 return [column.column];
12435 function padVerticalColumnheaders() {
12436 headers.forEach(
function (row, index) {
12437 row.forEach(
function (header) {
12438 if (!header.children) {
12439 header.height = headers.length - index;
12445 function addCalcRow(calcs, selector, pos) {
12446 var calcData = calcs[selector];
12450 calcData = calcData[pos];
12453 if (Object.keys(calcData).length) {
12455 processRows([calcData]);
12461 if (config.columnHeaders) {
12462 if (config.columnHeaders ==
"groups") {
12464 var actualColumns = [];
12466 columns.forEach(
function (column) {
12467 actualColumns = actualColumns.concat(parseColumnGroup(column, 0));
12470 columns = actualColumns;
12472 padVerticalColumnheaders();
12473 generateHeaders(headers);
12475 generateSimpleHeaders();
12482 body = document.createElement(
"tbody");
12485 if (window.getComputedStyle) {
12486 oddRow = this.table.element.querySelector(
".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)");
12487 evenRow = this.table.element.querySelector(
".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)");
12488 calcRow = this.table.element.querySelector(
".tabulator-row.tabulator-calcs");
12489 firstRow = this.table.element.querySelector(
".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)");
12490 firstGroup = this.table.element.getElementsByClassName(
"tabulator-group")[0];
12493 styleCells = firstRow.getElementsByClassName(
"tabulator-cell");
12494 firstCell = styleCells[0];
12495 lastCell = styleCells[styleCells.length - 1];
12499 function processRows(rowArray) {
12501 rowArray.forEach(
function (row, i) {
12502 var rowEl = document.createElement(
"tr"),
12503 styleRow = firstRow,
12507 if (row instanceof RowComponent) {
12508 rowData = row.getData(
"clipboard");
12514 columns.forEach(
function (column, j) {
12515 var cellEl = document.createElement(
"td"),
12516 value = column.getFieldValue(rowData);
12518 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
12520 value = JSON.stringify(value);
12532 cellEl.innerHTML = value;
12534 if (column.definition.align) {
12535 cellEl.style.textAlign = column.definition.align;
12538 if (j < columns.length - 1) {
12540 self.mapElementStyles(firstCell, cellEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"color",
"font-weight",
"font-family",
"font-size"]);
12544 self.mapElementStyles(firstCell, cellEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"color",
"font-weight",
"font-family",
"font-size"]);
12548 rowEl.appendChild(cellEl);
12552 styleRow = calcRow;
12554 if (!(i % 2) && oddRow) {
12558 if (i % 2 && evenRow) {
12559 styleRow = evenRow;
12564 self.mapElementStyles(styleRow, rowEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"color",
"font-weight",
"font-family",
"font-size",
"background-color"]);
12567 body.appendChild(rowEl);
12571 function processGroup(group, calcObj) {
12572 var groupEl = document.createElement(
"tr"),
12573 groupCellEl = document.createElement(
"td");
12575 groupCellEl.colSpan = columns.length;
12577 groupCellEl.innerHTML = group.key;
12579 groupEl.appendChild(groupCellEl);
12580 body.appendChild(groupEl);
12582 self.mapElementStyles(firstGroup, groupEl, [
"border-top",
"border-left",
"border-right",
"border-bottom",
"color",
"font-weight",
"font-family",
"font-size",
"background-color"]);
12584 if (group.subGroups) {
12585 group.subGroups.forEach(
function (subGroup) {
12586 processGroup(subGroup, calcObj[group.key] ? calcObj[group.key].groups || {} : {});
12589 if (config.columnCalcs) {
12590 addCalcRow(calcObj, group.key,
"top");
12593 processRows(group.rows);
12595 if (config.columnCalcs) {
12596 addCalcRow(calcObj, group.key,
"bottom");
12601 if (config.rowGroups) {
12602 rows.forEach(
function (group) {
12603 processGroup(group, calcs || {});
12606 if (config.columnCalcs) {
12607 addCalcRow(calcs,
"top");
12612 if (config.columnCalcs) {
12613 addCalcRow(calcs,
"bottom");
12617 this.htmlElement.appendChild(body);
12620 Clipboard.prototype.mapElementStyles =
function (from, to, props) {
12623 "background-color":
"backgroundColor",
12624 "color":
"fontColor",
12625 "font-weight":
"fontWeight",
12626 "font-family":
"fontFamily",
12627 "font-size":
"fontSize",
12628 "border-top":
"borderTop",
12629 "border-left":
"borderLeft",
12630 "border-right":
"borderRight",
12631 "border-bottom":
"borderBottom"
12634 if (window.getComputedStyle) {
12635 var fromStyle = window.getComputedStyle(from);
12637 props.forEach(
function (prop) {
12638 to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);
12645 Clipboard.prototype.copySelectors = {
12646 userSelection:
function userSelection(config, params) {
12649 selected:
function selected(config, params) {
12652 if (this.table.modExists(
"selectRow",
true)) {
12653 rows = this.table.modules.selectRow.getSelectedRows();
12656 if (config.rowGroups) {
12657 console.warn(
"Clipboard Warning - select coptSelector does not support row groups");
12660 return this.buildOutput(rows, config, params);
12662 table:
function table(config, params) {
12663 if (config.rowGroups) {
12664 console.warn(
"Clipboard Warning - table coptSelector does not support row groups");
12667 return this.buildOutput(this.table.rowManager.getComponents(), config, params);
12669 active:
function active(config, params) {
12672 if (config.rowGroups) {
12673 rows = this.buildComplexRows(config);
12675 rows = this.table.rowManager.getComponents(
"active");
12678 return this.buildOutput(rows, config, params);
12680 visible:
function visible(config, params) {
12683 if (config.rowGroups) {
12684 rows = this.buildComplexRows(config);
12686 rows = this.table.rowManager.getComponents(
"visible");
12689 return this.buildOutput(rows, config, params);
12693 Clipboard.prototype.copyFormatters = {
12694 raw:
function raw(data, params) {
12697 table:
function table(data, params) {
12700 data.forEach(
function (row) {
12702 row.forEach(
function (value) {
12703 if (typeof value ==
"undefined") {
12707 value = typeof value ==
"undefined" || value === null ?
"" : value.toString();
12709 if (value.match(/\r|\n/)) {
12710 value = value.split(
'"').join(
'""');
12711 value =
'"' + value +
'"';
12713 newRow.push(value);
12716 output.push(newRow.join(
"\t"));
12719 return output.join(
"\n");
12723 Clipboard.prototype.pasteParsers = {
12724 table:
function table(clipboard) {
12727 headerFindSuccess =
true,
12728 columns = this.table.columnManager.columns,
12733 clipboard = clipboard.split(
"\n");
12735 clipboard.forEach(
function (row) {
12736 data.push(row.split(
"\t"));
12739 if (data.length && !(data.length === 1 && data[0].length < 2)) {
12743 data[0].forEach(
function (value) {
12744 var column = columns.find(
function (column) {
12745 return value && column.definition.title && value.trim() && column.definition.title.trim() === value.trim();
12749 columnMap.push(column);
12751 headerFindSuccess =
false;
12756 if (!headerFindSuccess) {
12757 headerFindSuccess =
true;
12760 data[0].forEach(
function (value) {
12761 var column = columns.find(
function (column) {
12762 return value && column.field && value.trim() && column.field.trim() === value.trim();
12766 columnMap.push(column);
12768 headerFindSuccess =
false;
12772 if (!headerFindSuccess) {
12773 columnMap = this.table.columnManager.columnsByIndex;
12778 if (headerFindSuccess) {
12782 data.forEach(
function (item) {
12785 item.forEach(
function (value, i) {
12786 if (columnMap[i]) {
12787 row[columnMap[i].field] = value;
12801 Clipboard.prototype.pasteActions = {
12802 replace:
function replace(rows) {
12803 return this.table.setData(rows);
12805 update:
function update(rows) {
12806 return this.table.updateOrAddData(rows);
12808 insert:
function insert(rows) {
12809 return this.table.addData(rows);
12813 Tabulator.prototype.registerModule(
"clipboard", Clipboard);
12815 var DataTree =
function DataTree(table) {
12816 this.table = table;
12819 this.collapseEl = null;
12820 this.expandEl = null;
12821 this.branchEl = null;
12822 this.elementField =
false;
12824 this.startOpen =
function () {};
12826 this.displayIndex = 0;
12829 DataTree.prototype.initialize =
function () {
12830 var dummyEl = null,
12831 firstCol = this.table.columnManager.getFirstVisibileColumn(),
12832 options = this.table.options;
12834 this.field = options.dataTreeChildField;
12835 this.indent = options.dataTreeChildIndent;
12836 this.elementField = options.dataTreeElementColumn || (firstCol ? firstCol.field :
false);
12838 if (options.dataTreeBranchElement) {
12840 if (options.dataTreeBranchElement ===
true) {
12841 this.branchEl = document.createElement(
"div");
12842 this.branchEl.classList.add(
"tabulator-data-tree-branch");
12844 if (typeof options.dataTreeBranchElement ===
"string") {
12845 dummyEl = document.createElement(
"div");
12846 dummyEl.innerHTML = options.dataTreeBranchElement;
12847 this.branchEl = dummyEl.firstChild;
12849 this.branchEl = options.dataTreeBranchElement;
12854 if (options.dataTreeCollapseElement) {
12855 if (typeof options.dataTreeCollapseElement ===
"string") {
12856 dummyEl = document.createElement(
"div");
12857 dummyEl.innerHTML = options.dataTreeCollapseElement;
12858 this.collapseEl = dummyEl.firstChild;
12860 this.collapseEl = options.dataTreeCollapseElement;
12863 this.collapseEl = document.createElement(
"div");
12864 this.collapseEl.classList.add(
"tabulator-data-tree-control");
12865 this.collapseEl.tabIndex = 0;
12866 this.collapseEl.innerHTML =
"<div class='tabulator-data-tree-control-collapse'></div>";
12869 if (options.dataTreeExpandElement) {
12870 if (typeof options.dataTreeExpandElement ===
"string") {
12871 dummyEl = document.createElement(
"div");
12872 dummyEl.innerHTML = options.dataTreeExpandElement;
12873 this.expandEl = dummyEl.firstChild;
12875 this.expandEl = options.dataTreeExpandElement;
12878 this.expandEl = document.createElement(
"div");
12879 this.expandEl.classList.add(
"tabulator-data-tree-control");
12880 this.expandEl.tabIndex = 0;
12881 this.expandEl.innerHTML =
"<div class='tabulator-data-tree-control-expand'></div>";
12884 switch (_typeof(options.dataTreeStartExpanded)) {
12886 this.startOpen =
function (row, index) {
12887 return options.dataTreeStartExpanded;
12892 this.startOpen = options.dataTreeStartExpanded;
12896 this.startOpen =
function (row, index) {
12897 return options.dataTreeStartExpanded[index];
12903 DataTree.prototype.initializeRow =
function (row) {
12904 var childArray = row.getData()[this.field];
12905 var isArray = Array.isArray(childArray);
12907 var children = isArray || !isArray && (typeof childArray ===
'undefined' ?
'undefined' : _typeof(childArray)) ===
"object" && childArray !== null;
12909 row.modules.dataTree = {
12911 open: children ? this.startOpen(row.getComponent(), 0) :
false,
12919 DataTree.prototype.layoutRow =
function (row) {
12920 var cell = this.elementField ? row.getCell(this.elementField) : row.getCells()[0],
12921 el = cell.getElement(),
12922 config = row.modules.dataTree;
12924 if (config.branchEl) {
12925 config.branchEl.parentNode.removeChild(config.branchEl);
12928 this.generateControlElement(row, el);
12930 if (config.index) {
12931 if (this.branchEl) {
12932 config.branchEl = this.branchEl.cloneNode(
true);
12933 el.insertBefore(config.branchEl, el.firstChild);
12934 config.branchEl.style.marginLeft = (config.branchEl.offsetWidth + config.branchEl.style.marginRight) * (config.index - 1) + config.index * this.indent +
"px";
12936 el.style.paddingLeft = parseInt(window.getComputedStyle(el, null).getPropertyValue(
'padding-left')) + config.index *
this.indent +
"px";
12941 DataTree.prototype.generateControlElement =
function (row, el) {
12942 var _this39 =
this;
12944 var config = row.modules.dataTree,
12945 el = el || row.getCells()[0].getElement(),
12946 oldControl = config.controlEl;
12948 if (config.children !==
false) {
12951 config.controlEl = this.collapseEl.cloneNode(
true);
12952 config.controlEl.addEventListener(
"click",
function (e) {
12953 e.stopPropagation();
12954 _this39.collapseRow(row);
12957 config.controlEl = this.expandEl.cloneNode(
true);
12958 config.controlEl.addEventListener(
"click",
function (e) {
12959 e.stopPropagation();
12960 _this39.expandRow(row);
12964 config.controlEl.addEventListener(
"mousedown",
function (e) {
12965 e.stopPropagation();
12968 if (oldControl && oldControl.parentNode === el) {
12969 oldControl.parentNode.replaceChild(config.controlEl, oldControl);
12971 el.insertBefore(config.controlEl, el.firstChild);
12976 DataTree.prototype.setDisplayIndex =
function (index) {
12977 this.displayIndex = index;
12980 DataTree.prototype.getDisplayIndex =
function () {
12981 return this.displayIndex;
12984 DataTree.prototype.getRows =
function (rows) {
12985 var _this40 =
this;
12989 rows.forEach(
function (row, i) {
12990 var config, children;
12994 if (row instanceof Row) {
12996 config = row.modules.dataTree.children;
12998 if (!config.index && config.children !==
false) {
12999 children = _this40.getChildren(row);
13001 children.forEach(
function (child) {
13002 output.push(child);
13011 DataTree.prototype.getChildren =
function (row) {
13012 var _this41 =
this;
13014 var config = row.modules.dataTree,
13018 if (config.children !==
false && config.open) {
13019 if (!Array.isArray(config.children)) {
13020 config.children = this.generateChildren(row);
13023 if (this.table.modExists(
"filter")) {
13024 children = this.table.modules.filter.filter(config.children);
13026 children = config.children;
13029 if (this.table.modExists(
"sort")) {
13030 this.table.modules.sort.sort(children);
13033 children.forEach(
function (child) {
13034 output.push(child);
13036 var subChildren = _this41.getChildren(child);
13038 subChildren.forEach(
function (sub) {
13047 DataTree.prototype.generateChildren =
function (row) {
13048 var _this42 =
this;
13052 var childArray = row.getData()[this.field];
13054 if (!Array.isArray(childArray)) {
13055 childArray = [childArray];
13058 childArray.forEach(
function (childData) {
13059 var childRow =
new Row(childData || {}, _this42.table.rowManager);
13060 childRow.modules.dataTree.index = row.modules.dataTree.index + 1;
13061 childRow.modules.dataTree.parent = row;
13062 if (childRow.modules.dataTree.children) {
13063 childRow.modules.dataTree.open = _this42.startOpen(childRow.getComponent(), childRow.modules.dataTree.index);
13065 children.push(childRow);
13071 DataTree.prototype.expandRow =
function (row, silent) {
13072 var config = row.modules.dataTree;
13074 if (config.children !==
false) {
13075 config.open =
true;
13077 row.reinitialize();
13079 this.table.rowManager.refreshActiveData(
"tree",
false,
true);
13081 this.table.options.dataTreeRowExpanded(row.getComponent(), row.modules.dataTree.index);
13085 DataTree.prototype.collapseRow =
function (row) {
13086 var config = row.modules.dataTree;
13088 if (config.children !==
false) {
13089 config.open =
false;
13091 row.reinitialize();
13093 this.table.rowManager.refreshActiveData(
"tree",
false,
true);
13095 this.table.options.dataTreeRowCollapsed(row.getComponent(), row.modules.dataTree.index);
13099 DataTree.prototype.toggleRow =
function (row) {
13100 var config = row.modules.dataTree;
13102 if (config.children !==
false) {
13104 this.collapseRow(row);
13106 this.expandRow(row);
13111 DataTree.prototype.getTreeParent =
function (row) {
13112 return row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() :
false;
13115 DataTree.prototype.getTreeChildren =
function (row) {
13116 var config = row.modules.dataTree,
13119 if (config.children) {
13121 if (!Array.isArray(config.children)) {
13122 config.children = this.generateChildren(row);
13125 config.children.forEach(
function (childRow) {
13126 if (childRow instanceof Row) {
13127 output.push(childRow.getComponent());
13135 DataTree.prototype.checkForRestyle =
function (cell) {
13136 if (!cell.row.cells.indexOf(cell)) {
13137 if (cell.row.modules.dataTree.children !==
false) {
13138 cell.row.reinitialize();
13143 DataTree.prototype.getChildField =
function () {
13147 DataTree.prototype.redrawNeeded =
function (data) {
13148 return (this.field ? typeof data[this.field] !==
"undefined" :
false) || (this.elementField ? typeof data[this.elementField] !==
"undefined" :
false);
13151 Tabulator.prototype.registerModule(
"dataTree", DataTree);
13152 var Download =
function Download(table) {
13153 this.table = table;
13155 this.columnsByIndex = [];
13156 this.columnsByField = {};
13158 this.active =
false;
13162 Download.prototype.download =
function (type, filename, options, active, interceptCallback) {
13164 downloadFunc =
false;
13165 this.processConfig();
13166 this.active = active;
13168 function buildLink(data, mime) {
13169 if (interceptCallback) {
13170 if (interceptCallback ===
true) {
13171 self.triggerDownload(data, mime, type, filename,
true);
13173 interceptCallback(data);
13176 self.triggerDownload(data, mime, type, filename);
13180 if (typeof type ==
"function") {
13181 downloadFunc = type;
13183 if (
self.downloaders[type]) {
13184 downloadFunc =
self.downloaders[type];
13186 console.warn(
"Download Error - No such download type found: ", type);
13190 this.processColumns();
13192 if (downloadFunc) {
13193 downloadFunc.call(
this,
self.processDefinitions(),
self.processData(active ||
"active"), options || {}, buildLink, this.config);
13197 Download.prototype.processConfig =
function () {
13199 columnGroups:
true,
13204 if (this.table.options.downloadConfig) {
13205 for (var key in this.table.options.downloadConfig) {
13206 config[key] = this.table.options.downloadConfig[key];
13210 if (config.rowGroups &&
this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
13211 this.config.rowGroups =
true;
13214 if (config.columnGroups &&
this.table.columnManager.columns.length !=
this.table.columnManager.columnsByIndex.length) {
13215 this.config.columnGroups =
true;
13218 if (config.columnCalcs &&
this.table.modExists(
"columnCalcs")) {
13219 this.config.columnCalcs =
true;
13223 Download.prototype.processColumns =
function () {
13226 self.columnsByIndex = [];
13227 self.columnsByField = {};
13229 self.table.columnManager.columnsByIndex.forEach(
function (column) {
13231 if (column.field && column.definition.download !==
false && (column.visible || !column.visible && column.definition.download)) {
13232 self.columnsByIndex.push(column);
13233 self.columnsByField[column.field] = column;
13238 Download.prototype.processDefinitions =
function () {
13240 processedDefinitions = [];
13242 if (this.config.columnGroups) {
13243 self.table.columnManager.columns.forEach(
function (column) {
13244 var colData =
self.processColumnGroup(column);
13247 processedDefinitions.push(colData);
13251 self.columnsByIndex.forEach(
function (column) {
13252 if (column.download !==
false) {
13254 processedDefinitions.push(
self.processDefinition(column));
13259 return processedDefinitions;
13262 Download.prototype.processColumnGroup =
function (column) {
13263 var _this43 =
this;
13265 var subGroups = column.columns,
13267 var processedColumn = this.processDefinition(column);
13270 title: processedColumn.title,
13274 if (subGroups.length) {
13275 groupData.subGroups = [];
13276 groupData.width = 0;
13278 subGroups.forEach(
function (subGroup) {
13279 var subGroupData = _this43.processColumnGroup(subGroup);
13281 if (subGroupData.depth > maxDepth) {
13282 maxDepth = subGroupData.depth;
13285 if (subGroupData) {
13286 groupData.width += subGroupData.width;
13287 groupData.subGroups.push(subGroupData);
13291 groupData.depth += maxDepth;
13293 if (!groupData.width) {
13297 if (column.field && column.definition.download !==
false && (column.visible || !column.visible && column.definition.download)) {
13298 groupData.width = 1;
13299 groupData.definition = processedColumn;
13308 Download.prototype.processDefinition =
function (column) {
13311 for (var key in column.definition) {
13312 def[key] = column.definition[key];
13315 if (typeof column.definition.downloadTitle !=
"undefined") {
13316 def.title = column.definition.downloadTitle;
13322 Download.prototype.processData =
function (active) {
13323 var _this44 =
this;
13331 if (this.config.rowGroups) {
13333 if (active ==
"visible") {
13335 rows =
self.table.rowManager.getRows(active);
13337 rows.forEach(
function (row) {
13338 if (row.type ==
"row") {
13339 var group = row.getGroup();
13341 if (groups.indexOf(group) === -1) {
13342 groups.push(group);
13347 groups = this.table.modules.groupRows.getGroups();
13350 groups.forEach(
function (group) {
13351 data.push(_this44.processGroupData(group, rows));
13354 data =
self.table.rowManager.getData(active,
"download");
13357 if (this.config.columnCalcs) {
13358 calcs = this.table.getCalcResults();
13367 if (typeof
self.table.options.downloadDataFormatter ==
"function") {
13368 data =
self.table.options.downloadDataFormatter(data);
13374 Download.prototype.processGroupData =
function (group, visRows) {
13375 var _this45 =
this;
13377 var subGroups = group.getSubGroups();
13384 if (subGroups.length) {
13385 groupData.subGroups = [];
13387 subGroups.forEach(
function (subGroup) {
13388 groupData.subGroups.push(_this45.processGroupData(subGroup, visRows));
13392 groupData.rows = [];
13394 group.rows.forEach(
function (row) {
13395 if (visRows.indexOf(row) > -1) {
13396 groupData.rows.push(row.getData(
"download"));
13400 groupData.rows = group.getData(
true,
"download");
13407 Download.prototype.triggerDownload =
function (data, mime, type, filename, newTab) {
13408 var element = document.createElement(
'a'),
13409 blob =
new Blob([data], { type: mime }),
13410 filename = filename ||
"Tabulator." + (typeof type ===
"function" ?
"txt" : type);
13412 blob = this.table.options.downloadReady.call(this.table, data, blob);
13417 window.open(window.URL.createObjectURL(blob));
13419 if (navigator.msSaveOrOpenBlob) {
13420 navigator.msSaveOrOpenBlob(blob, filename);
13422 element.setAttribute(
'href', window.URL.createObjectURL(blob));
13425 element.setAttribute(
'download', filename);
13428 element.style.display =
'none';
13429 document.body.appendChild(element);
13433 document.body.removeChild(element);
13437 if (this.table.options.downloadComplete) {
13438 this.table.options.downloadComplete();
13444 Download.prototype.getFieldValue =
function (field, data) {
13445 var column = this.columnsByField[field];
13448 return column.getFieldValue(data);
13454 Download.prototype.commsReceived =
function (table, action, data) {
13457 this.download(data.type,
"", data.options, data.active, data.intercept);
13463 Download.prototype.downloaders = {
13464 csv:
function csv(columns, data, options, setFileContents, config) {
13468 delimiter = options && options.delimiter ? options.delimiter :
",",
13473 function parseSimpleTitles() {
13474 columns.forEach(
function (column) {
13475 titles.push(
'"' + String(column.title).split(
'"').join(
'""') +
'"');
13476 fields.push(column.field);
13480 function parseColumnGroup(column, level) {
13481 if (column.subGroups) {
13482 column.subGroups.forEach(
function (subGroup) {
13483 parseColumnGroup(subGroup, level + 1);
13486 titles.push(
'"' + String(column.title).split(
'"').join(
'""') +
'"');
13487 fields.push(column.definition.field);
13491 if (config.columnGroups) {
13492 console.warn(
"Download Warning - CSV downloader cannot process column groups");
13494 columns.forEach(
function (column) {
13495 parseColumnGroup(column, 0);
13498 parseSimpleTitles();
13502 fileContents = [titles.join(delimiter)];
13504 function parseRows(data) {
13506 data.forEach(
function (row) {
13509 fields.forEach(
function (field) {
13510 var value =
self.getFieldValue(field, row);
13512 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
13514 value = JSON.stringify(value);
13527 rowData.push(
'"' + String(value).split(
'"').join(
'""') +
'"');
13530 fileContents.push(rowData.join(delimiter));
13534 function parseGroup(group) {
13535 if (group.subGroups) {
13536 group.subGroups.forEach(
function (subGroup) {
13537 parseGroup(subGroup);
13540 parseRows(group.rows);
13544 if (config.columnCalcs) {
13545 console.warn(
"Download Warning - CSV downloader cannot process column calculations");
13549 if (config.rowGroups) {
13550 console.warn(
"Download Warning - CSV downloader cannot process row groups");
13552 data.forEach(
function (group) {
13559 output = fileContents.join(
"\n");
13562 output =
'\uFEFF' + output;
13565 setFileContents(output,
"text/csv");
13568 json:
function json(columns, data, options, setFileContents, config) {
13571 if (config.columnCalcs) {
13572 console.warn(
"Download Warning - CSV downloader cannot process column calculations");
13576 fileContents = JSON.stringify(data, null,
'\t');
13578 setFileContents(fileContents,
"application/json");
13581 pdf:
function pdf(columns, data, options, setFileContents, config) {
13589 autoTableParams = {},
13590 rowGroupStyles = options.rowGroupStyles || {
13596 rowCalcStyles = options.rowCalcStyles || {
13602 jsPDFParams = options.jsPDF || {},
13603 title = options && options.title ? options.title :
"";
13605 if (config.columnCalcs) {
13606 calcs = data.calcs;
13610 if (!jsPDFParams.orientation) {
13611 jsPDFParams.orientation = options.orientation ||
"landscape";
13614 if (!jsPDFParams.unit) {
13615 jsPDFParams.unit =
"pt";
13619 function parseSimpleTitles() {
13620 columns.forEach(
function (column) {
13621 if (column.field) {
13622 header.push(column.title ||
"");
13623 fields.push(column.field);
13630 function parseColumnGroup(column, level) {
13631 var colSpan = column.width,
13634 content: column.title ||
""
13637 if (column.subGroups) {
13638 column.subGroups.forEach(
function (subGroup) {
13639 parseColumnGroup(subGroup, level + 1);
13643 fields.push(column.definition.field);
13644 rowSpan = headerDepth - level;
13647 col.rowSpan = rowSpan;
13650 header[level].push(col);
13655 for (var i = level + 1; i < headerDepth; i++) {
13656 header[i].push(
"");
13660 for (var i = 0; i < colSpan; i++) {
13661 header[level].push(
"");
13665 if (config.columnGroups) {
13666 columns.forEach(
function (column) {
13667 if (column.depth > headerDepth) {
13668 headerDepth = column.depth;
13672 for (var i = 0; i < headerDepth; i++) {
13676 columns.forEach(
function (column) {
13677 parseColumnGroup(column, 0);
13680 parseSimpleTitles();
13683 function parseValue(value) {
13684 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
13686 value = JSON.stringify(value);
13701 function parseRows(data) {
13703 data.forEach(
function (row) {
13704 body.push(parseRow(row));
13708 function parseRow(row, styles) {
13711 fields.forEach(
function (field) {
13712 var value =
self.getFieldValue(field, row);
13713 value = parseValue(value);
13721 rowData.push(value);
13728 function parseGroup(group, calcObj) {
13729 var groupData = [];
13731 groupData.push({ content: parseValue(group.key), colSpan: fields.length, styles: rowGroupStyles });
13733 body.push(groupData);
13735 if (group.subGroups) {
13736 group.subGroups.forEach(
function (subGroup) {
13737 parseGroup(subGroup, calcObj[group.key] ? calcObj[group.key].groups || {} : {});
13741 if (config.columnCalcs) {
13742 addCalcRow(calcObj, group.key,
"top");
13745 parseRows(group.rows);
13747 if (config.columnCalcs) {
13748 addCalcRow(calcObj, group.key,
"bottom");
13753 function addCalcRow(calcs, selector, pos) {
13754 var calcData = calcs[selector];
13758 calcData = calcData[pos];
13761 if (Object.keys(calcData).length) {
13762 body.push(parseRow(calcData, rowCalcStyles));
13767 if (config.rowGroups) {
13768 data.forEach(
function (group) {
13769 parseGroup(group, calcs);
13772 if (config.columnCalcs) {
13773 addCalcRow(calcs,
"top");
13778 if (config.columnCalcs) {
13779 addCalcRow(calcs,
"bottom");
13783 var doc =
new jsPDF(jsPDFParams);
13785 if (options && options.autoTable) {
13786 if (typeof options.autoTable ===
"function") {
13787 autoTableParams = options.autoTable(doc) || {};
13789 autoTableParams = options.autoTable;
13794 autoTableParams.addPageContent =
function (data) {
13795 doc.text(title, 40, 30);
13799 autoTableParams.head = header;
13800 autoTableParams.body = body;
13802 doc.autoTable(autoTableParams);
13804 if (options && options.documentProcessing) {
13805 options.documentProcessing(doc);
13808 setFileContents(doc.output(
"arraybuffer"),
"application/pdf");
13811 xlsx:
function xlsx(columns, data, options, setFileContents, config) {
13813 sheetName = options.sheetName ||
"Sheet1",
13814 workbook = XLSX.utils.book_new(),
13816 groupRowIndexs = [],
13817 groupColumnIndexs = [],
13818 calcRowIndexs = [],
13821 workbook.SheetNames = [];
13822 workbook.Sheets = {};
13824 if (config.columnCalcs) {
13825 calcs = data.calcs;
13829 function generateSheet() {
13836 function rowsToSheet() {
13838 var range = { s: { c: 0, r: 0 }, e: { c: fields.length, r: rows.length } };
13840 XLSX.utils.sheet_add_aoa(sheet, rows);
13842 sheet[
'!ref'] = XLSX.utils.encode_range(range);
13844 var merges = generateMerges();
13846 if (merges.length) {
13847 sheet[
"!merges"] = merges;
13853 function parseSimpleTitles() {
13855 columns.forEach(
function (column) {
13856 titles.push(column.title);
13857 fields.push(column.field);
13863 function parseColumnGroup(column, level) {
13865 if (typeof titles[level] ===
"undefined") {
13866 titles[level] = [];
13869 if (typeof groupColumnIndexs[level] ===
"undefined") {
13870 groupColumnIndexs[level] = [];
13873 if (column.width > 1) {
13875 groupColumnIndexs[level].push({
13877 start: titles[level].length,
13878 end: titles[level].length + column.width - 1
13882 titles[level].push(column.title);
13884 if (column.subGroups) {
13885 column.subGroups.forEach(
function (subGroup) {
13886 parseColumnGroup(subGroup, level + 1);
13889 fields.push(column.definition.field);
13890 padColumnTitles(fields.length - 1, level);
13892 groupColumnIndexs[level].push({
13894 start: fields.length - 1
13899 function padColumnTitles() {
13902 titles.forEach(
function (title) {
13903 var len = title.length;
13909 titles.forEach(
function (title) {
13910 var len = title.length;
13912 for (var i = len; i < max; i++) {
13919 if (config.columnGroups) {
13920 columns.forEach(
function (column) {
13921 parseColumnGroup(column, 0);
13924 titles.forEach(
function (title) {
13928 parseSimpleTitles();
13931 function generateMerges() {
13934 groupRowIndexs.forEach(
function (index) {
13935 output.push({ s: { r: index, c: 0 }, e: { r: index, c: fields.length - 1 } });
13938 groupColumnIndexs.forEach(
function (merges, level) {
13939 merges.forEach(
function (merge) {
13940 if (merge.type ===
"hoz") {
13941 output.push({ s: { r: level, c: merge.start }, e: { r: level, c: merge.end } });
13943 if (level != titles.length - 1) {
13944 output.push({ s: { r: level, c: merge.start }, e: { r: titles.length - 1, c: merge.start } });
13954 function parseRows(data) {
13955 data.forEach(
function (row) {
13956 rows.push(parseRow(row));
13960 function parseRow(row) {
13963 fields.forEach(
function (field) {
13964 var value =
self.getFieldValue(field, row);
13965 rowData.push(!(value instanceof Date) && (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) ===
"object" ? JSON.stringify(value) : value);
13971 function addCalcRow(calcs, selector, pos) {
13972 var calcData = calcs[selector];
13976 calcData = calcData[pos];
13979 if (Object.keys(calcData).length) {
13980 calcRowIndexs.push(rows.length);
13981 rows.push(parseRow(calcData));
13986 function parseGroup(group, calcObj) {
13987 var groupData = [];
13989 groupData.push(group.key);
13991 groupRowIndexs.push(rows.length);
13993 rows.push(groupData);
13995 if (group.subGroups) {
13996 group.subGroups.forEach(
function (subGroup) {
13997 parseGroup(subGroup, calcObj[group.key] ? calcObj[group.key].groups || {} : {});
14001 if (config.columnCalcs) {
14002 addCalcRow(calcObj, group.key,
"top");
14005 parseRows(group.rows);
14007 if (config.columnCalcs) {
14008 addCalcRow(calcObj, group.key,
"bottom");
14013 if (config.rowGroups) {
14014 data.forEach(
function (group) {
14015 parseGroup(group, calcs);
14018 if (config.columnCalcs) {
14019 addCalcRow(calcs,
"top");
14024 if (config.columnCalcs) {
14025 addCalcRow(calcs,
"bottom");
14029 worksheet = rowsToSheet();
14034 if (options.sheetOnly) {
14035 setFileContents(generateSheet());
14039 if (options.sheets) {
14040 for (var sheet in options.sheets) {
14042 if (options.sheets[sheet] ===
true) {
14043 workbook.SheetNames.push(sheet);
14044 workbook.Sheets[sheet] = generateSheet();
14047 workbook.SheetNames.push(sheet);
14049 this.table.modules.comms.send(options.sheets[sheet],
"download",
"intercept", {
14051 options: { sheetOnly:
true },
14052 active:
self.active,
14053 intercept:
function intercept(data) {
14054 workbook.Sheets[sheet] = data;
14060 workbook.SheetNames.push(sheetName);
14061 workbook.Sheets[sheetName] = generateSheet();
14064 if (options.documentProcessing) {
14065 workbook = options.documentProcessing(workbook);
14070 var buf =
new ArrayBuffer(s.length);
14071 var view =
new Uint8Array(buf);
14072 for (var i = 0; i != s.length; ++i) {
14073 view[i] = s.charCodeAt(i) & 0xFF;
14077 output = XLSX.write(workbook, { bookType:
'xlsx', bookSST:
true, type:
'binary' });
14079 setFileContents(s2ab(output),
"application/octet-stream");
14082 html:
function html(columns, data, options, setFileContents, config) {
14083 if (this.table.modExists(
"htmlTableExport",
true)) {
14084 setFileContents(this.table.modules.htmlTableExport.getHtml(
true, options.style, config),
"text/html");
14090 Tabulator.prototype.registerModule(
"download", Download);
14092 var Edit =
function Edit(table) {
14093 this.table = table;
14094 this.currentCell =
false;
14095 this.mouseClick =
false;
14096 this.recursionBlock =
false;
14097 this.invalidEdit =
false;
14101 Edit.prototype.initializeColumn =
function (column) {
14106 check: column.definition.editable,
14107 params: column.definition.editorParams || {}
14111 switch (_typeof(column.definition.editor)) {
14114 if (column.definition.editor ===
"tick") {
14115 column.definition.editor =
"tickCross";
14116 console.warn(
"DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor");
14119 if (
self.editors[column.definition.editor]) {
14120 config.editor =
self.editors[column.definition.editor];
14122 console.warn(
"Editor Error - No such editor found: ", column.definition.editor);
14127 config.editor = column.definition.editor;
14132 if (column.definition.editor ===
true) {
14134 if (typeof column.definition.formatter !==
"function") {
14136 if (column.definition.formatter ===
"tick") {
14137 column.definition.formatter =
"tickCross";
14138 console.warn(
"DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor");
14141 if (
self.editors[column.definition.formatter]) {
14142 config.editor =
self.editors[column.definition.formatter];
14144 config.editor =
self.editors[
"input"];
14147 console.warn(
"Editor Error - Cannot auto lookup editor for a custom formatter: ", column.definition.formatter);
14153 if (config.editor) {
14154 column.modules.edit = config;
14158 Edit.prototype.getCurrentCell =
function () {
14159 return this.currentCell ? this.currentCell.getComponent() :
false;
14162 Edit.prototype.clearEditor =
function () {
14163 var cell = this.currentCell,
14166 this.invalidEdit =
false;
14169 this.currentCell =
false;
14171 cellEl = cell.getElement();
14172 cellEl.classList.remove(
"tabulator-validation-fail");
14173 cellEl.classList.remove(
"tabulator-editing");
14174 while (cellEl.firstChild) {
14175 cellEl.removeChild(cellEl.firstChild);
14176 }cell.row.getElement().classList.remove(
"tabulator-row-editing");
14180 Edit.prototype.cancelEdit =
function () {
14182 if (this.currentCell) {
14183 var cell = this.currentCell;
14184 var component = this.currentCell.getComponent();
14186 this.clearEditor();
14187 cell.setValueActual(cell.getValue());
14189 if (cell.column.cellEvents.cellEditCancelled) {
14190 cell.column.cellEvents.cellEditCancelled.call(this.table, component);
14193 this.table.options.cellEditCancelled.call(this.table, component);
14198 Edit.prototype.bindEditor =
function (cell) {
14200 element = cell.getElement();
14202 element.setAttribute(
"tabindex", 0);
14204 element.addEventListener(
"click",
function (e) {
14205 if (!element.classList.contains(
"tabulator-editing")) {
14210 element.addEventListener(
"mousedown",
function (e) {
14211 self.mouseClick =
true;
14214 element.addEventListener(
"focus",
function (e) {
14215 if (!
self.recursionBlock) {
14216 self.edit(cell, e,
false);
14221 Edit.prototype.focusCellNoEvent =
function (cell, block) {
14222 this.recursionBlock =
true;
14223 if (!(block && this.table.browser ===
"ie")) {
14224 cell.getElement().focus();
14226 this.recursionBlock =
false;
14229 Edit.prototype.editCell =
function (cell, forceEdit) {
14230 this.focusCellNoEvent(cell);
14231 this.edit(cell,
false, forceEdit);
14234 Edit.prototype.edit =
function (cell, e, forceEdit) {
14237 rendered =
function rendered() {},
14238 element = cell.getElement(),
14244 if (this.currentCell) {
14245 if (!this.invalidEdit) {
14252 function success(value) {
14254 if (
self.currentCell === cell) {
14257 if (cell.column.modules.validate &&
self.table.modExists(
"validate")) {
14258 valid =
self.table.modules.validate.validate(cell.column.modules.validate, cell.getComponent(), value);
14261 if (valid ===
true) {
14262 self.clearEditor();
14263 cell.setValue(value,
true);
14265 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
14266 self.table.modules.dataTree.checkForRestyle(cell);
14271 self.invalidEdit =
true;
14272 element.classList.add(
"tabulator-validation-fail");
14273 self.focusCellNoEvent(cell,
true);
14275 self.table.options.validationFailed.call(
self.table, cell.getComponent(), value, valid);
14285 function cancel() {
14286 if (
self.currentCell === cell) {
14289 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
14290 self.table.modules.dataTree.checkForRestyle(cell);
14297 function onRendered(callback) {
14298 rendered = callback;
14301 if (!cell.column.modules.edit.blocked) {
14303 e.stopPropagation();
14306 switch (_typeof(cell.column.modules.edit.check)) {
14308 allowEdit = cell.column.modules.edit.check(cell.getComponent());
14312 allowEdit = cell.column.modules.edit.check;
14316 if (allowEdit || forceEdit) {
14320 self.currentCell = cell;
14322 component = cell.getComponent();
14324 if (this.mouseClick) {
14325 this.mouseClick =
false;
14327 if (cell.column.cellEvents.cellClick) {
14328 cell.column.cellEvents.cellClick.call(this.table, e, component);
14332 if (cell.column.cellEvents.cellEditing) {
14333 cell.column.cellEvents.cellEditing.call(this.table, component);
14336 self.table.options.cellEditing.call(this.table, component);
14338 params = typeof cell.column.modules.edit.params ===
"function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;
14340 cellEditor = cell.column.modules.edit.editor.call(
self, component, onRendered, success, cancel, params);
14343 if (cellEditor !==
false) {
14345 if (cellEditor instanceof Node) {
14346 element.classList.add(
"tabulator-editing");
14347 cell.row.getElement().classList.add(
"tabulator-row-editing");
14348 while (element.firstChild) {
14349 element.removeChild(element.firstChild);
14350 }element.appendChild(cellEditor);
14356 var children = element.children;
14358 for (var i = 0; i < children.length; i++) {
14359 children[i].addEventListener(
"click",
function (e) {
14360 e.stopPropagation();
14364 console.warn(
"Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor);
14375 this.mouseClick =
false;
14380 this.mouseClick =
false;
14387 Edit.prototype.editors = {
14390 input:
function input(cell, onRendered, success, cancel, editorParams) {
14393 var cellValue = cell.getValue(),
14394 input = document.createElement(
"input");
14396 input.setAttribute(
"type", editorParams.search ?
"search" :
"text");
14398 input.style.padding =
"4px";
14399 input.style.width =
"100%";
14400 input.style.boxSizing =
"border-box";
14402 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
14403 for (var key in editorParams.elementAttributes) {
14404 if (key.charAt(0) ==
"+") {
14405 key = key.slice(1);
14406 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
14408 input.setAttribute(key, editorParams.elementAttributes[key]);
14413 input.value = typeof cellValue !==
"undefined" ? cellValue :
"";
14415 onRendered(
function () {
14417 input.style.height =
"100%";
14420 function onChange(e) {
14421 if ((cellValue === null || typeof cellValue ===
"undefined") && input.value !==
"" || input.value != cellValue) {
14423 if (success(input.value)) {
14424 cellValue = input.value;
14432 input.addEventListener(
"change", onChange);
14433 input.addEventListener(
"blur", onChange);
14436 input.addEventListener(
"keydown",
function (e) {
14437 switch (e.keyCode) {
14452 textarea:
function textarea(cell, onRendered, success, cancel, editorParams) {
14454 cellValue = cell.getValue(),
14455 vertNav = editorParams.verticalNavigation ||
"hybrid",
14456 value = String(cellValue !== null && typeof cellValue !==
"undefined" ? cellValue :
""),
14457 count = (value.match(/(?:\r\n|\r|\n)/g) || []).length + 1,
14458 input = document.createElement(
"textarea"),
14462 input.style.display =
"block";
14463 input.style.padding =
"2px";
14464 input.style.height =
"100%";
14465 input.style.width =
"100%";
14466 input.style.boxSizing =
"border-box";
14467 input.style.whiteSpace =
"pre-wrap";
14468 input.style.resize =
"none";
14470 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
14471 for (var key in editorParams.elementAttributes) {
14472 if (key.charAt(0) ==
"+") {
14473 key = key.slice(1);
14474 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
14476 input.setAttribute(key, editorParams.elementAttributes[key]);
14481 input.value = value;
14483 onRendered(
function () {
14485 input.style.height =
"100%";
14488 function onChange(e) {
14490 if ((cellValue === null || typeof cellValue ===
"undefined") && input.value !==
"" || input.value != cellValue) {
14492 if (success(input.value)) {
14493 cellValue = input.value;
14496 setTimeout(
function () {
14497 cell.getRow().normalizeHeight();
14505 input.addEventListener(
"change", onChange);
14506 input.addEventListener(
"blur", onChange);
14508 input.addEventListener(
"keyup",
function () {
14510 input.style.height =
"";
14512 var heightNow = input.scrollHeight;
14514 input.style.height = heightNow +
"px";
14516 if (heightNow != scrollHeight) {
14517 scrollHeight = heightNow;
14518 cell.getRow().normalizeHeight();
14522 input.addEventListener(
"keydown",
function (e) {
14524 switch (e.keyCode) {
14531 if (vertNav ==
"editor" || vertNav ==
"hybrid" && input.selectionStart) {
14532 e.stopImmediatePropagation();
14533 e.stopPropagation();
14540 if (vertNav ==
"editor" || vertNav ==
"hybrid" && input.selectionStart !== input.value.length) {
14541 e.stopImmediatePropagation();
14542 e.stopPropagation();
14552 number:
function number(cell, onRendered, success, cancel, editorParams) {
14554 var cellValue = cell.getValue(),
14555 vertNav = editorParams.verticalNavigation ||
"editor",
14556 input = document.createElement(
"input");
14558 input.setAttribute(
"type",
"number");
14560 if (typeof editorParams.max !=
"undefined") {
14561 input.setAttribute(
"max", editorParams.max);
14564 if (typeof editorParams.min !=
"undefined") {
14565 input.setAttribute(
"min", editorParams.min);
14568 if (typeof editorParams.step !=
"undefined") {
14569 input.setAttribute(
"step", editorParams.step);
14573 input.style.padding =
"4px";
14574 input.style.width =
"100%";
14575 input.style.boxSizing =
"border-box";
14577 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
14578 for (var key in editorParams.elementAttributes) {
14579 if (key.charAt(0) ==
"+") {
14580 key = key.slice(1);
14581 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
14583 input.setAttribute(key, editorParams.elementAttributes[key]);
14588 input.value = cellValue;
14590 var blurFunc =
function blurFunc(e) {
14594 onRendered(
function () {
14596 input.removeEventListener(
"blur", blurFunc);
14599 input.style.height =
"100%";
14602 input.addEventListener(
"blur", blurFunc);
14605 function onChange() {
14606 var value = input.value;
14608 if (!isNaN(value) && value !==
"") {
14609 value = Number(value);
14612 if (value != cellValue) {
14613 if (success(value)) {
14622 input.addEventListener(
"keydown",
function (e) {
14623 switch (e.keyCode) {
14636 if (vertNav ==
"editor") {
14637 e.stopImmediatePropagation();
14638 e.stopPropagation();
14648 range:
function range(cell, onRendered, success, cancel, editorParams) {
14650 var cellValue = cell.getValue(),
14651 input = document.createElement(
"input");
14653 input.setAttribute(
"type",
"range");
14655 if (typeof editorParams.max !=
"undefined") {
14656 input.setAttribute(
"max", editorParams.max);
14659 if (typeof editorParams.min !=
"undefined") {
14660 input.setAttribute(
"min", editorParams.min);
14663 if (typeof editorParams.step !=
"undefined") {
14664 input.setAttribute(
"step", editorParams.step);
14668 input.style.padding =
"4px";
14669 input.style.width =
"100%";
14670 input.style.boxSizing =
"border-box";
14672 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
14673 for (var key in editorParams.elementAttributes) {
14674 if (key.charAt(0) ==
"+") {
14675 key = key.slice(1);
14676 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
14678 input.setAttribute(key, editorParams.elementAttributes[key]);
14683 input.value = cellValue;
14685 onRendered(
function () {
14687 input.style.height =
"100%";
14690 function onChange() {
14691 var value = input.value;
14693 if (!isNaN(value) && value !==
"") {
14694 value = Number(value);
14697 if (value != cellValue) {
14698 if (success(value)) {
14707 input.addEventListener(
"blur",
function (e) {
14712 input.addEventListener(
"keydown",
function (e) {
14713 switch (e.keyCode) {
14729 select:
function select(cell, onRendered, success, cancel, editorParams) {
14731 cellEl = cell.getElement(),
14732 initialValue = cell.getValue(),
14733 vertNav = editorParams.verticalNavigation ||
"editor",
14734 initialDisplayValue = typeof initialValue !==
"undefined" || initialValue === null ? initialValue : typeof editorParams.defaultValue !==
"undefined" ? editorParams.defaultValue :
"",
14735 input = document.createElement(
"input"),
14736 listEl = document.createElement(
"div"),
14742 this.table.rowManager.element.addEventListener(
"scroll", cancelItem);
14744 if (Array.isArray(editorParams) || !Array.isArray(editorParams) && (typeof editorParams ===
'undefined' ?
'undefined' : _typeof(editorParams)) ===
"object" && !editorParams.values) {
14745 console.warn(
"DEPRECATION WANRING - values for the select editor must now be passed into the values property of the editorParams object, not as the editorParams object");
14746 editorParams = { values: editorParams };
14749 function getUniqueColumnValues(field) {
14751 data =
self.table.getData(),
14755 column =
self.table.columnManager.getColumnByField(field);
14757 column = cell.getColumn()._getSelf();
14761 data.forEach(
function (row) {
14762 var val = column.getFieldValue(row);
14764 if (val !== null && typeof val !==
"undefined" && val !==
"") {
14765 output[val] =
true;
14769 if (editorParams.sortValuesList) {
14770 if (editorParams.sortValuesList ==
"asc") {
14771 output = Object.keys(output).sort();
14773 output = Object.keys(output).sort().reverse();
14776 output = Object.keys(output);
14779 console.warn(
"unable to find matching column to create select lookup list:", field);
14785 function parseItems(inputValues, curentValue) {
14787 var displayList = [];
14789 function processComplexListItem(item) {
14791 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(item.value, item.label) : item.label,
14796 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
14797 setCurrentItem(item);
14800 dataList.push(item);
14801 displayList.push(item);
14806 if (typeof inputValues ==
"function") {
14807 inputValues = inputValues(cell);
14810 if (Array.isArray(inputValues)) {
14811 inputValues.forEach(
function (value) {
14814 if ((typeof value ===
'undefined' ?
'undefined' : _typeof(value)) ===
"object") {
14816 if (value.options) {
14818 label: value.label,
14823 displayList.push(item);
14825 value.options.forEach(
function (item) {
14826 processComplexListItem(item);
14829 processComplexListItem(value);
14834 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
14839 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
14840 setCurrentItem(item);
14843 dataList.push(item);
14844 displayList.push(item);
14848 for (var key in inputValues) {
14850 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
14855 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
14856 setCurrentItem(item);
14859 dataList.push(item);
14860 displayList.push(item);
14864 dataItems = dataList;
14865 displayItems = displayList;
14870 function fillList() {
14871 while (listEl.firstChild) {
14872 listEl.removeChild(listEl.firstChild);
14873 }displayItems.forEach(
function (item) {
14874 var el = item.element;
14879 el = document.createElement(
"div");
14880 el.classList.add(
"tabulator-edit-select-list-group");
14882 el.innerHTML = item.label ===
"" ?
" " : item.label;
14884 el = document.createElement(
"div");
14885 el.classList.add(
"tabulator-edit-select-list-item");
14887 el.innerHTML = item.label ===
"" ?
" " : item.label;
14889 el.addEventListener(
"click",
function () {
14890 setCurrentItem(item);
14894 if (item === currentItem) {
14895 el.classList.add(
"active");
14899 el.addEventListener(
"mousedown",
function () {
14902 setTimeout(
function () {
14910 listEl.appendChild(el);
14914 function setCurrentItem(item) {
14916 if (currentItem && currentItem.element) {
14917 currentItem.element.classList.remove(
"active");
14920 currentItem = item;
14921 input.value = item.label ===
" " ?
"" : item.label;
14923 if (item.element) {
14924 item.element.classList.add(
"active");
14928 function chooseItem() {
14931 if (initialValue !== currentItem.value) {
14932 initialValue = currentItem.value;
14933 success(currentItem.value);
14939 function cancelItem() {
14944 function showList() {
14945 if (!listEl.parentNode) {
14947 if (editorParams.values ===
true) {
14948 parseItems(getUniqueColumnValues(), initialDisplayValue);
14949 }
else if (typeof editorParams.values ===
"string") {
14950 parseItems(getUniqueColumnValues(editorParams.values), initialDisplayValue);
14952 parseItems(editorParams.values || [], initialDisplayValue);
14955 var offset = Tabulator.prototype.helpers.elOffset(cellEl);
14957 listEl.style.minWidth = cellEl.offsetWidth +
"px";
14959 listEl.style.top = offset.top + cellEl.offsetHeight +
"px";
14960 listEl.style.left = offset.left +
"px";
14961 document.body.appendChild(listEl);
14965 function hideList() {
14966 if (listEl.parentNode) {
14967 listEl.parentNode.removeChild(listEl);
14970 removeScrollListener();
14973 function removeScrollListener() {
14974 self.table.rowManager.element.removeEventListener(
"scroll", cancelItem);
14978 input.setAttribute(
"type",
"text");
14980 input.style.padding =
"4px";
14981 input.style.width =
"100%";
14982 input.style.boxSizing =
"border-box";
14983 input.style.cursor =
"default";
14984 input.readOnly = this.currentCell !=
false;
14986 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
14987 for (var key in editorParams.elementAttributes) {
14988 if (key.charAt(0) ==
"+") {
14989 key = key.slice(1);
14990 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
14992 input.setAttribute(key, editorParams.elementAttributes[key]);
14997 input.value = typeof initialValue !==
"undefined" || initialValue === null ? initialValue :
"";
15008 input.addEventListener(
"keydown",
function (e) {
15011 switch (e.keyCode) {
15014 index = dataItems.indexOf(currentItem);
15016 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index) {
15017 e.stopImmediatePropagation();
15018 e.stopPropagation();
15019 e.preventDefault();
15022 setCurrentItem(dataItems[index - 1]);
15029 index = dataItems.indexOf(currentItem);
15031 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index < dataItems.length - 1) {
15032 e.stopImmediatePropagation();
15033 e.stopPropagation();
15034 e.preventDefault();
15036 if (index < dataItems.length - 1) {
15038 setCurrentItem(dataItems[0]);
15040 setCurrentItem(dataItems[index + 1]);
15049 e.stopImmediatePropagation();
15050 e.stopPropagation();
15051 e.preventDefault();
15066 input.addEventListener(
"blur",
function (e) {
15072 input.addEventListener(
"focus",
function (e) {
15077 listEl = document.createElement(
"div");
15078 listEl.classList.add(
"tabulator-edit-select-list");
15080 onRendered(
function () {
15081 input.style.height =
"100%";
15089 autocomplete:
function autocomplete(cell, onRendered, success, cancel, editorParams) {
15091 cellEl = cell.getElement(),
15092 initialValue = cell.getValue(),
15093 vertNav = editorParams.verticalNavigation ||
"editor",
15094 initialDisplayValue = typeof initialValue !==
"undefined" || initialValue === null ? initialValue : typeof editorParams.defaultValue !==
"undefined" ? editorParams.defaultValue :
"",
15095 input = document.createElement(
"input"),
15096 listEl = document.createElement(
"div"),
15103 this.table.rowManager.element.addEventListener(
"scroll", cancelItem);
15105 function getUniqueColumnValues(field) {
15107 data =
self.table.getData(),
15111 column =
self.table.columnManager.getColumnByField(field);
15113 column = cell.getColumn()._getSelf();
15117 data.forEach(
function (row) {
15118 var val = column.getFieldValue(row);
15120 if (val !== null && typeof val !==
"undefined" && val !==
"") {
15121 output[val] =
true;
15125 if (editorParams.sortValuesList) {
15126 if (editorParams.sortValuesList ==
"asc") {
15127 output = Object.keys(output).sort();
15129 output = Object.keys(output).sort().reverse();
15132 output = Object.keys(output);
15135 console.warn(
"unable to find matching column to create autocomplete lookup list:", field);
15141 function parseItems(inputValues, curentValue) {
15144 if (Array.isArray(inputValues)) {
15145 inputValues.forEach(
function (value) {
15147 title: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
15152 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
15153 setCurrentItem(item);
15156 itemList.push(item);
15159 for (var key in inputValues) {
15161 title: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
15166 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
15167 setCurrentItem(item);
15170 itemList.push(item);
15174 if (editorParams.searchFunc) {
15175 itemList.forEach(
function (item) {
15183 allItems = itemList;
15186 function filterList(term, intialLoad) {
15189 searchResults = [];
15191 if (editorParams.searchFunc) {
15193 allItems.forEach(
function (item) {
15194 searchObjs.push(item.search);
15197 searchResults = editorParams.searchFunc(term, searchObjs);
15199 searchResults.forEach(
function (result) {
15200 var match = allItems.find(
function (item) {
15201 return item.search === result;
15205 matches.push(match);
15211 if (editorParams.showListOnEmpty) {
15212 allItems.forEach(
function (item) {
15213 matches.push(item);
15217 allItems.forEach(
function (item) {
15219 if (item.value !== null || typeof item.value !==
"undefined") {
15220 if (String(item.value).toLowerCase().indexOf(String(term).toLowerCase()) > -1 || String(item.title).toLowerCase().indexOf(String(term).toLowerCase()) > -1) {
15221 matches.push(item);
15228 displayItems = matches;
15230 fillList(intialLoad);
15233 function fillList(intialLoad) {
15234 var current =
false;
15236 while (listEl.firstChild) {
15237 listEl.removeChild(listEl.firstChild);
15238 }displayItems.forEach(
function (item) {
15239 var el = item.element;
15242 el = document.createElement(
"div");
15243 el.classList.add(
"tabulator-edit-select-list-item");
15245 el.innerHTML = item.title;
15247 el.addEventListener(
"click",
function () {
15248 setCurrentItem(item);
15252 el.addEventListener(
"mousedown",
function () {
15255 setTimeout(
function () {
15262 if (intialLoad && item.value == initialValue) {
15263 input.value = item.title;
15264 item.element.classList.add(
"active");
15268 if (item === currentItem) {
15269 item.element.classList.add(
"active");
15274 listEl.appendChild(el);
15278 setCurrentItem(
false);
15282 function setCurrentItem(item, showInputValue) {
15283 if (currentItem && currentItem.element) {
15284 currentItem.element.classList.remove(
"active");
15287 currentItem = item;
15289 if (item && item.element) {
15290 item.element.classList.add(
"active");
15294 function chooseItem() {
15298 if (initialValue !== currentItem.value) {
15299 initialValue = currentItem.value;
15300 input.value = currentItem.title;
15301 success(currentItem.value);
15306 if (editorParams.freetext) {
15307 initialValue = input.value;
15308 success(input.value);
15310 if (editorParams.allowEmpty && input.value ===
"") {
15311 initialValue = input.value;
15312 success(input.value);
15320 function cancelItem() {
15325 function showList() {
15326 if (!listEl.parentNode) {
15327 while (listEl.firstChild) {
15328 listEl.removeChild(listEl.firstChild);
15329 }
if (editorParams.values ===
true) {
15330 values = getUniqueColumnValues();
15331 }
else if (typeof editorParams.values ===
"string") {
15332 values = getUniqueColumnValues(editorParams.values);
15334 values = editorParams.values || [];
15337 parseItems(values, initialValue);
15339 var offset = Tabulator.prototype.helpers.elOffset(cellEl);
15341 listEl.style.minWidth = cellEl.offsetWidth +
"px";
15343 listEl.style.top = offset.top + cellEl.offsetHeight +
"px";
15344 listEl.style.left = offset.left +
"px";
15345 document.body.appendChild(listEl);
15349 function hideList() {
15350 if (listEl.parentNode) {
15351 listEl.parentNode.removeChild(listEl);
15354 removeScrollListener();
15357 function removeScrollListener() {
15358 self.table.rowManager.element.removeEventListener(
"scroll", cancelItem);
15362 input.setAttribute(
"type",
"search");
15364 input.style.padding =
"4px";
15365 input.style.width =
"100%";
15366 input.style.boxSizing =
"border-box";
15368 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
15369 for (var key in editorParams.elementAttributes) {
15370 if (key.charAt(0) ==
"+") {
15371 key = key.slice(1);
15372 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
15374 input.setAttribute(key, editorParams.elementAttributes[key]);
15380 input.addEventListener(
"keydown",
function (e) {
15383 switch (e.keyCode) {
15386 index = displayItems.indexOf(currentItem);
15388 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index) {
15389 e.stopImmediatePropagation();
15390 e.stopPropagation();
15391 e.preventDefault();
15394 setCurrentItem(displayItems[index - 1]);
15396 setCurrentItem(
false);
15404 index = displayItems.indexOf(currentItem);
15406 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index < displayItems.length - 1) {
15408 e.stopImmediatePropagation();
15409 e.stopPropagation();
15410 e.preventDefault();
15412 if (index < displayItems.length - 1) {
15414 setCurrentItem(displayItems[0]);
15416 setCurrentItem(displayItems[index + 1]);
15425 e.stopImmediatePropagation();
15426 e.stopPropagation();
15427 e.preventDefault();
15444 e.stopImmediatePropagation();
15449 input.addEventListener(
"keyup",
function (e) {
15451 switch (e.keyCode) {
15462 filterList(input.value);
15466 input.addEventListener(
"search",
function (e) {
15467 filterList(input.value);
15470 input.addEventListener(
"blur",
function (e) {
15476 input.addEventListener(
"focus",
function (e) {
15477 var value = initialDisplayValue;
15479 input.value = value;
15480 filterList(value,
true);
15484 listEl = document.createElement(
"div");
15485 listEl.classList.add(
"tabulator-edit-select-list");
15487 onRendered(
function () {
15488 input.style.height =
"100%";
15496 star:
function star(cell, onRendered, success, cancel, editorParams) {
15498 element = cell.getElement(),
15499 value = cell.getValue(),
15500 maxStars = element.getElementsByTagName(
"svg").length || 5,
15501 size = element.getElementsByTagName(
"svg")[0] ? element.getElementsByTagName(
"svg")[0].getAttribute(
"width") : 14,
15503 starsHolder = document.createElement(
"div"),
15504 star = document.createElementNS(
'http://www.w3.org/2000/svg',
"svg");
15507 function starChange(val) {
15508 stars.forEach(
function (star, i) {
15510 if (
self.table.browser ==
"ie") {
15511 star.setAttribute(
"class",
"tabulator-star-active");
15513 star.classList.replace(
"tabulator-star-inactive",
"tabulator-star-active");
15516 star.innerHTML =
'<polygon fill="#488CE9" stroke="#014AAE" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';
15518 if (
self.table.browser ==
"ie") {
15519 star.setAttribute(
"class",
"tabulator-star-inactive");
15521 star.classList.replace(
"tabulator-star-active",
"tabulator-star-inactive");
15524 star.innerHTML =
'<polygon fill="#010155" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';
15530 function buildStar(i) {
15532 var starHolder = document.createElement(
"span");
15533 var nextStar = star.cloneNode(
true);
15535 stars.push(nextStar);
15537 starHolder.addEventListener(
"mouseenter",
function (e) {
15538 e.stopPropagation();
15539 e.stopImmediatePropagation();
15543 starHolder.addEventListener(
"mousemove",
function (e) {
15544 e.stopPropagation();
15545 e.stopImmediatePropagation();
15548 starHolder.addEventListener(
"click",
function (e) {
15549 e.stopPropagation();
15550 e.stopImmediatePropagation();
15554 starHolder.appendChild(nextStar);
15555 starsHolder.appendChild(starHolder);
15559 function changeValue(val) {
15565 element.style.whiteSpace =
"nowrap";
15566 element.style.overflow =
"hidden";
15567 element.style.textOverflow =
"ellipsis";
15570 starsHolder.style.verticalAlign =
"middle";
15571 starsHolder.style.display =
"inline-block";
15572 starsHolder.style.padding =
"4px";
15575 star.setAttribute(
"width", size);
15576 star.setAttribute(
"height", size);
15577 star.setAttribute(
"viewBox",
"0 0 512 512");
15578 star.setAttribute(
"xml:space",
"preserve");
15579 star.style.padding =
"0 1px";
15581 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
15582 for (var key in editorParams.elementAttributes) {
15583 if (key.charAt(0) ==
"+") {
15584 key = key.slice(1);
15585 starsHolder.setAttribute(key, starsHolder.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
15587 starsHolder.setAttribute(key, editorParams.elementAttributes[key]);
15593 for (var i = 1; i <= maxStars; i++) {
15598 value = Math.min(parseInt(value), maxStars);
15603 starsHolder.addEventListener(
"mousemove",
function (e) {
15607 starsHolder.addEventListener(
"click",
function (e) {
15611 element.addEventListener(
"blur",
function (e) {
15616 element.addEventListener(
"keydown",
function (e) {
15617 switch (e.keyCode) {
15620 changeValue(value + 1);
15625 changeValue(value - 1);
15640 return starsHolder;
15644 progress:
function progress(cell, onRendered, success, cancel, editorParams) {
15645 var element = cell.getElement(),
15646 max = typeof editorParams.max ===
"undefined" ? element.getElementsByTagName(
"div")[0].getAttribute(
"max") || 100 : editorParams.max,
15647 min = typeof editorParams.min ===
"undefined" ? element.getElementsByTagName(
"div")[0].getAttribute(
"min") || 0 : editorParams.min,
15648 percent = (max - min) / 100,
15649 value = cell.getValue() || 0,
15650 handle = document.createElement(
"div"),
15651 bar = document.createElement(
"div"),
15656 function updateValue() {
15657 var calcVal = percent * Math.round(bar.offsetWidth / (element.clientWidth / 100)) + min;
15659 element.setAttribute(
"aria-valuenow", calcVal);
15660 element.setAttribute(
"aria-label", value);
15664 handle.style.position =
"absolute";
15665 handle.style.right =
"0";
15666 handle.style.top =
"0";
15667 handle.style.bottom =
"0";
15668 handle.style.width =
"5px";
15669 handle.classList.add(
"tabulator-progress-handle");
15672 bar.style.display =
"inline-block";
15673 bar.style.position =
"relative";
15678 bar.style.height =
"100%";
15679 bar.style.backgroundColor =
"#488CE9";
15680 bar.style.maxWidth =
"100%";
15681 bar.style.minWidth =
"0%";
15683 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
15684 for (var key in editorParams.elementAttributes) {
15685 if (key.charAt(0) ==
"+") {
15686 key = key.slice(1);
15687 bar.setAttribute(key, bar.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
15689 bar.setAttribute(key, editorParams.elementAttributes[key]);
15695 element.style.padding =
"4px 4px";
15698 value = Math.min(parseFloat(value), max);
15699 value = Math.max(parseFloat(value), min);
15702 value = Math.round((value - min) / percent);
15704 bar.style.width = value +
"%";
15706 element.setAttribute(
"aria-valuemin", min);
15707 element.setAttribute(
"aria-valuemax", max);
15709 bar.appendChild(handle);
15711 handle.addEventListener(
"mousedown",
function (e) {
15712 mouseDrag = e.screenX;
15713 mouseDragWidth = bar.offsetWidth;
15716 handle.addEventListener(
"mouseover",
function () {
15717 handle.style.cursor =
"ew-resize";
15720 element.addEventListener(
"mousemove",
function (e) {
15722 bar.style.width = mouseDragWidth + e.screenX - mouseDrag +
"px";
15726 element.addEventListener(
"mouseup",
function (e) {
15728 e.stopPropagation();
15729 e.stopImmediatePropagation();
15732 mouseDragWidth =
false;
15739 element.addEventListener(
"keydown",
function (e) {
15740 switch (e.keyCode) {
15743 bar.style.width = bar.clientWidth + element.clientWidth / 100 +
"px";
15748 bar.style.width = bar.clientWidth - element.clientWidth / 100 +
"px";
15764 element.addEventListener(
"blur",
function () {
15772 tickCross:
function tickCross(cell, onRendered, success, cancel, editorParams) {
15773 var value = cell.getValue(),
15774 input = document.createElement(
"input"),
15775 tristate = editorParams.tristate,
15776 indetermValue = typeof editorParams.indeterminateValue ===
"undefined" ? null : editorParams.indeterminateValue,
15777 indetermState =
false;
15779 input.setAttribute(
"type",
"checkbox");
15780 input.style.marginTop =
"5px";
15781 input.style.boxSizing =
"border-box";
15783 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
15784 for (var key in editorParams.elementAttributes) {
15785 if (key.charAt(0) ==
"+") {
15786 key = key.slice(1);
15787 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
15789 input.setAttribute(key, editorParams.elementAttributes[key]);
15794 input.value = value;
15796 if (tristate && (typeof value ===
"undefined" || value === indetermValue || value ===
"")) {
15797 indetermState =
true;
15798 input.indeterminate =
true;
15801 if (this.table.browser !=
"firefox") {
15803 onRendered(
function () {
15808 input.checked = value ===
true || value ===
"true" || value ===
"True" || value === 1;
15810 function setValue(blur) {
15813 if (input.checked && !indetermState) {
15814 input.checked =
false;
15815 input.indeterminate =
true;
15816 indetermState =
true;
15817 return indetermValue;
15819 indetermState =
false;
15820 return input.checked;
15823 if (indetermState) {
15824 return indetermValue;
15826 return input.checked;
15830 return input.checked;
15835 input.addEventListener(
"change",
function (e) {
15836 success(setValue());
15839 input.addEventListener(
"blur",
function (e) {
15840 success(setValue(
true));
15844 input.addEventListener(
"keydown",
function (e) {
15845 if (e.keyCode == 13) {
15846 success(setValue());
15848 if (e.keyCode == 27) {
15857 Tabulator.prototype.registerModule(
"edit", Edit);
15859 var Filter =
function Filter(table) {
15861 this.table = table;
15863 this.filterList = [];
15864 this.headerFilters = {};
15865 this.headerFilterColumns = [];
15867 this.changed =
false;
15871 Filter.prototype.initializeColumn =
function (column, value) {
15873 field = column.getField(),
15877 function success(value) {
15878 var filterType = column.modules.filter.tagType ==
"input" && column.modules.filter.attrType ==
"text" || column.modules.filter.tagType ==
"textarea" ?
"partial" :
"match",
15882 if (typeof column.modules.filter.prevSuccess ===
"undefined" || column.modules.filter.prevSuccess !== value) {
15884 column.modules.filter.prevSuccess = value;
15886 if (!column.modules.filter.emptyFunc(value)) {
15887 column.modules.filter.value = value;
15889 switch (_typeof(column.definition.headerFilterFunc)) {
15891 if (
self.filters[column.definition.headerFilterFunc]) {
15892 type = column.definition.headerFilterFunc;
15893 filterFunc =
function filterFunc(data) {
15894 var params = column.definition.headerFilterFuncParams || {};
15895 var fieldVal = column.getFieldValue(data);
15897 params = typeof params ===
"function" ? params(value, fieldVal, data) : params;
15899 return self.filters[column.definition.headerFilterFunc](value, fieldVal, data, params);
15902 console.warn(
"Header Filter Error - Matching filter function not found: ", column.definition.headerFilterFunc);
15907 filterFunc =
function filterFunc(data) {
15908 var params = column.definition.headerFilterFuncParams || {};
15909 var fieldVal = column.getFieldValue(data);
15911 params = typeof params ===
"function" ? params(value, fieldVal, data) : params;
15913 return column.definition.headerFilterFunc(value, fieldVal, data, params);
15921 switch (filterType) {
15923 filterFunc =
function filterFunc(data) {
15924 var colVal = column.getFieldValue(data);
15926 if (typeof colVal !==
'undefined' && colVal !== null) {
15927 return String(colVal).toLowerCase().indexOf(String(value).toLowerCase()) > -1;
15936 filterFunc =
function filterFunc(data) {
15937 return column.getFieldValue(data) == value;
15943 self.headerFilters[field] = { value: value, func: filterFunc, type: type };
15945 delete self.headerFilters[field];
15948 self.changed =
true;
15950 self.table.rowManager.filterRefresh();
15956 column.modules.filter = {
15963 this.generateHeaderFilterElement(column);
15966 Filter.prototype.generateHeaderFilterElement =
function (column, initialValue, reinitialize) {
15967 var _this46 =
this;
15970 success = column.modules.filter.success,
15971 field = column.getField(),
15981 function cancel() {}
15983 if (column.modules.filter.headerElement && column.modules.filter.headerElement.parentNode) {
15984 column.contentElement.removeChild(column.modules.filter.headerElement.parentNode);
15990 column.modules.filter.emptyFunc = column.definition.headerFilterEmptyCheck ||
function (value) {
15991 return !value && value !==
"0";
15994 filterElement = document.createElement(
"div");
15995 filterElement.classList.add(
"tabulator-header-filter");
15998 switch (_typeof(column.definition.headerFilter)) {
16000 if (
self.table.modules.edit.editors[column.definition.headerFilter]) {
16001 editor =
self.table.modules.edit.editors[column.definition.headerFilter];
16003 if ((column.definition.headerFilter ===
"tick" || column.definition.headerFilter ===
"tickCross") && !column.definition.headerFilterEmptyCheck) {
16004 column.modules.filter.emptyFunc =
function (value) {
16005 return value !==
true && value !==
false;
16009 console.warn(
"Filter Error - Cannot build header filter, No such editor found: ", column.definition.editor);
16014 editor = column.definition.headerFilter;
16018 if (column.modules.edit && column.modules.edit.editor) {
16019 editor = column.modules.edit.editor;
16021 if (column.definition.formatter &&
self.table.modules.edit.editors[column.definition.formatter]) {
16022 editor =
self.table.modules.edit.editors[column.definition.formatter];
16024 if ((column.definition.formatter ===
"tick" || column.definition.formatter ===
"tickCross") && !column.definition.headerFilterEmptyCheck) {
16025 column.modules.filter.emptyFunc =
function (value) {
16026 return value !==
true && value !==
false;
16030 editor =
self.table.modules.edit.editors[
"input"];
16039 getValue:
function getValue() {
16040 return typeof initialValue !==
"undefined" ? initialValue :
"";
16042 getField:
function getField() {
16043 return column.definition.field;
16045 getElement:
function getElement() {
16046 return filterElement;
16048 getColumn:
function getColumn() {
16049 return column.getComponent();
16051 getRow:
function getRow() {
16053 normalizeHeight:
function normalizeHeight() {}
16058 params = column.definition.headerFilterParams || {};
16060 params = typeof params ===
"function" ? params.call(
self.table) : params;
16062 editorElement = editor.call(this.table.modules.edit, cellWrapper, function () {}, success, cancel, params);
16064 if (!editorElement) {
16065 console.warn(
"Filter Error - Cannot add filter to " + field +
" column, editor returned a value of false");
16069 if (!(editorElement instanceof Node)) {
16070 console.warn(
"Filter Error - Cannot add filter to " + field +
" column, editor should return an instance of Node, the editor returned:", editorElement);
16076 self.table.modules.localize.bind(
"headerFilters|columns|" + column.definition.field, function (value) {
16077 editorElement.setAttribute(
"placeholder", typeof value !==
"undefined" && value ? value :
self.table.modules.localize.getText(
"headerFilters|default"));
16080 self.table.modules.localize.bind(
"headerFilters|default",
function (value) {
16081 editorElement.setAttribute(
"placeholder", typeof
self.column.definition.headerFilterPlaceholder !==
"undefined" &&
self.column.definition.headerFilterPlaceholder ?
self.column.definition.headerFilterPlaceholder : value);
16086 editorElement.addEventListener(
"click",
function (e) {
16087 e.stopPropagation();
16088 editorElement.focus();
16091 editorElement.addEventListener(
"focus",
function (e) {
16092 var left = _this46.table.columnManager.element.scrollLeft;
16094 if (left !== _this46.table.rowManager.element.scrollLeft) {
16095 _this46.table.rowManager.scrollHorizontal(left);
16096 _this46.table.columnManager.scrollHorizontal(left);
16101 typingTimer =
false;
16103 searchTrigger =
function searchTrigger(e) {
16105 clearTimeout(typingTimer);
16108 typingTimer = setTimeout(
function () {
16109 success(editorElement.value);
16113 column.modules.filter.headerElement = editorElement;
16114 column.modules.filter.attrType = editorElement.hasAttribute(
"type") ? editorElement.getAttribute(
"type").toLowerCase() :
"";
16115 column.modules.filter.tagType = editorElement.tagName.toLowerCase();
16117 if (column.definition.headerFilterLiveFilter !==
false) {
16119 if (!(column.definition.headerFilter ===
'autocomplete' || column.definition.headerFilter ===
'tickCross' || (column.definition.editor ===
'autocomplete' || column.definition.editor ===
'tickCross') && column.definition.headerFilter ===
true)) {
16120 editorElement.addEventListener(
"keyup", searchTrigger);
16121 editorElement.addEventListener(
"search", searchTrigger);
16124 if (column.modules.filter.attrType ==
"number") {
16125 editorElement.addEventListener(
"change",
function (e) {
16126 success(editorElement.value);
16131 if (column.modules.filter.attrType ==
"text" &&
this.table.browser !==
"ie") {
16132 editorElement.setAttribute(
"type",
"search");
16138 if (column.modules.filter.tagType ==
"input" || column.modules.filter.tagType ==
"select" || column.modules.filter.tagType ==
"textarea") {
16139 editorElement.addEventListener(
"mousedown",
function (e) {
16140 e.stopPropagation();
16145 filterElement.appendChild(editorElement);
16147 column.contentElement.appendChild(filterElement);
16149 if (!reinitialize) {
16150 self.headerFilterColumns.push(column);
16154 console.warn(
"Filter Error - Cannot add header filter, column has no field set:", column.definition.title);
16159 Filter.prototype.hideHeaderFilterElements =
function () {
16160 this.headerFilterColumns.forEach(
function (column) {
16161 if (column.modules.filter && column.modules.filter.headerElement) {
16162 column.modules.filter.headerElement.style.display =
'none';
16168 Filter.prototype.showHeaderFilterElements =
function () {
16169 this.headerFilterColumns.forEach(
function (column) {
16170 if (column.modules.filter && column.modules.filter.headerElement) {
16171 column.modules.filter.headerElement.style.display =
'';
16177 Filter.prototype.setHeaderFilterFocus =
function (column) {
16178 if (column.modules.filter && column.modules.filter.headerElement) {
16179 column.modules.filter.headerElement.focus();
16181 console.warn(
"Column Filter Focus Error - No header filter set on column:", column.getField());
16186 Filter.prototype.setHeaderFilterValue =
function (column, value) {
16188 if (column.modules.filter && column.modules.filter.headerElement) {
16189 this.generateHeaderFilterElement(column, value,
true);
16190 column.modules.filter.success(value);
16192 console.warn(
"Column Filter Error - No header filter set on column:", column.getField());
16197 Filter.prototype.reloadHeaderFilter =
function (column) {
16199 if (column.modules.filter && column.modules.filter.headerElement) {
16200 this.generateHeaderFilterElement(column, column.modules.filter.value,
true);
16202 console.warn(
"Column Filter Error - No header filter set on column:", column.getField());
16208 Filter.prototype.hasChanged =
function () {
16209 var changed = this.changed;
16210 this.changed =
false;
16215 Filter.prototype.setFilter =
function (field, type, value) {
16218 self.filterList = [];
16220 if (!Array.isArray(field)) {
16221 field = [{ field: field, type: type, value: value }];
16224 self.addFilter(field);
16228 Filter.prototype.addFilter =
function (field, type, value) {
16231 if (!Array.isArray(field)) {
16232 field = [{ field: field, type: type, value: value }];
16235 field.forEach(
function (filter) {
16237 filter =
self.findFilter(filter);
16240 self.filterList.push(filter);
16242 self.changed =
true;
16246 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.filter) {
16247 this.table.modules.persistence.save(
"filter");
16251 Filter.prototype.findFilter =
function (filter) {
16255 if (Array.isArray(filter)) {
16256 return this.findSubFilters(filter);
16259 var filterFunc =
false;
16261 if (typeof filter.field ==
"function") {
16262 filterFunc =
function filterFunc(data) {
16263 return filter.field(data, filter.type || {});
16267 if (
self.filters[filter.type]) {
16269 column =
self.table.columnManager.getColumnByField(filter.field);
16272 filterFunc =
function filterFunc(data) {
16273 return self.filters[filter.type](filter.value, column.getFieldValue(data));
16276 filterFunc =
function filterFunc(data) {
16277 return self.filters[filter.type](filter.value, data[filter.field]);
16281 console.warn(
"Filter Error - No such filter type found, ignoring: ", filter.type);
16285 filter.func = filterFunc;
16287 return filter.func ? filter :
false;
16290 Filter.prototype.findSubFilters =
function (filters) {
16294 filters.forEach(
function (filter) {
16295 filter =
self.findFilter(filter);
16298 output.push(filter);
16302 return output.length ? output :
false;
16306 Filter.prototype.getFilters =
function (all, ajax) {
16310 output = this.getHeaderFilters();
16314 output.forEach(
function (item) {
16315 if (typeof item.type ==
"function") {
16316 item.type =
"function";
16321 output = output.concat(this.filtersToArray(this.filterList, ajax));
16327 Filter.prototype.filtersToArray =
function (filterList, ajax) {
16328 var _this47 =
this;
16332 filterList.forEach(
function (filter) {
16335 if (Array.isArray(filter)) {
16336 output.push(_this47.filtersToArray(filter, ajax));
16338 item = { field: filter.field, type: filter.type, value: filter.value };
16341 if (typeof item.type ==
"function") {
16342 item.type =
"function";
16354 Filter.prototype.getHeaderFilters =
function () {
16358 for (var key in this.headerFilters) {
16359 output.push({ field: key, type: this.headerFilters[key].type, value: this.headerFilters[key].value });
16366 Filter.prototype.removeFilter =
function (field, type, value) {
16369 if (!Array.isArray(field)) {
16370 field = [{ field: field, type: type, value: value }];
16373 field.forEach(
function (filter) {
16376 if (_typeof(filter.field) ==
"object") {
16377 index =
self.filterList.findIndex(function (element) {
16378 return filter === element;
16381 index =
self.filterList.findIndex(
function (element) {
16382 return filter.field === element.field && filter.type === element.type && filter.value === element.value;
16387 self.filterList.splice(index, 1);
16388 self.changed =
true;
16390 console.warn(
"Filter Error - No matching filter type found, ignoring: ", filter.type);
16394 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.filter) {
16395 this.table.modules.persistence.save(
"filter");
16400 Filter.prototype.clearFilter =
function (all) {
16401 this.filterList = [];
16404 this.clearHeaderFilter();
16407 this.changed =
true;
16409 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.filter) {
16410 this.table.modules.persistence.save(
"filter");
16415 Filter.prototype.clearHeaderFilter =
function () {
16418 this.headerFilters = {};
16420 this.headerFilterColumns.forEach(
function (column) {
16421 column.modules.filter.value = null;
16422 column.modules.filter.prevSuccess = undefined;
16423 self.reloadHeaderFilter(column);
16426 this.changed =
true;
16430 Filter.prototype.search =
function (searchType, field, type, value) {
16435 if (!Array.isArray(field)) {
16436 field = [{ field: field, type: type, value: value }];
16439 field.forEach(
function (filter) {
16440 filter =
self.findFilter(filter);
16443 filterList.push(filter);
16447 this.table.rowManager.rows.forEach(
function (row) {
16450 filterList.forEach(
function (filter) {
16451 if (!
self.filterRecurse(filter, row.getData())) {
16457 activeRows.push(searchType ===
"data" ? row.getData(
"data") : row.getComponent());
16465 Filter.prototype.filter =
function (rowList, filters) {
16468 activeRowComponents = [];
16470 if (
self.table.options.dataFiltering) {
16471 self.table.options.dataFiltering.call(
self.table,
self.getFilters());
16474 if (!
self.table.options.ajaxFiltering && (
self.filterList.length || Object.keys(
self.headerFilters).length)) {
16476 rowList.forEach(
function (row) {
16477 if (
self.filterRow(row)) {
16478 activeRows.push(row);
16482 activeRows = rowList.slice(0);
16485 if (
self.table.options.dataFiltered) {
16487 activeRows.forEach(
function (row) {
16488 activeRowComponents.push(row.getComponent());
16491 self.table.options.dataFiltered.call(
self.table,
self.getFilters(), activeRowComponents);
16498 Filter.prototype.filterRow =
function (row, filters) {
16501 data = row.getData();
16503 self.filterList.forEach(
function (filter) {
16504 if (!
self.filterRecurse(filter, data)) {
16509 for (var field in
self.headerFilters) {
16510 if (!
self.headerFilters[field].func(data)) {
16518 Filter.prototype.filterRecurse =
function (filter, data) {
16522 if (Array.isArray(filter)) {
16523 filter.forEach(
function (subFilter) {
16524 if (
self.filterRecurse(subFilter, data)) {
16529 match = filter.func(data);
16536 Filter.prototype.filters = {
16539 "=":
function _(filterVal, rowVal, rowData, filterParams) {
16540 return rowVal == filterVal ?
true :
false;
16544 "<":
function _(filterVal, rowVal, rowData, filterParams) {
16545 return rowVal < filterVal ?
true :
false;
16549 "<=":
function _(filterVal, rowVal, rowData, filterParams) {
16550 return rowVal <= filterVal ?
true :
false;
16554 ">":
function _(filterVal, rowVal, rowData, filterParams) {
16555 return rowVal > filterVal ?
true :
false;
16559 ">=":
function _(filterVal, rowVal, rowData, filterParams) {
16560 return rowVal >= filterVal ?
true :
false;
16564 "!=":
function _(filterVal, rowVal, rowData, filterParams) {
16565 return rowVal != filterVal ?
true :
false;
16568 "regex":
function regex(filterVal, rowVal, rowData, filterParams) {
16570 if (typeof filterVal ==
"string") {
16571 filterVal =
new RegExp(filterVal);
16574 return filterVal.test(rowVal);
16578 "like":
function like(filterVal, rowVal, rowData, filterParams) {
16579 if (filterVal === null || typeof filterVal ===
"undefined") {
16580 return rowVal === filterVal ?
true :
false;
16582 if (typeof rowVal !==
'undefined' && rowVal !== null) {
16583 return String(rowVal).toLowerCase().indexOf(filterVal.toLowerCase()) > -1;
16591 "in":
function _in(filterVal, rowVal, rowData, filterParams) {
16592 if (Array.isArray(filterVal)) {
16593 return filterVal.indexOf(rowVal) > -1;
16595 console.warn(
"Filter Error - filter value is not an array:", filterVal);
16601 Tabulator.prototype.registerModule(
"filter", Filter);
16602 var Format =
function Format(table) {
16603 this.table = table;
16607 Format.prototype.initializeColumn =
function (column) {
16609 config = { params: column.definition.formatterParams || {} };
16612 switch (_typeof(column.definition.formatter)) {
16615 if (column.definition.formatter ===
"tick") {
16616 column.definition.formatter =
"tickCross";
16618 if (typeof config.params.crossElement ==
"undefined") {
16619 config.params.crossElement =
false;
16622 console.warn(
"DEPRECATION WARNING - the tick formatter has been deprecated, please use the tickCross formatter with the crossElement param set to false");
16625 if (
self.formatters[column.definition.formatter]) {
16626 config.formatter =
self.formatters[column.definition.formatter];
16628 console.warn(
"Formatter Error - No such formatter found: ", column.definition.formatter);
16629 config.formatter =
self.formatters.plaintext;
16634 config.formatter = column.definition.formatter;
16638 config.formatter =
self.formatters.plaintext;
16642 column.modules.format = config;
16645 Format.prototype.cellRendered =
function (cell) {
16646 if (cell.modules.format && cell.modules.format.renderedCallback) {
16647 cell.modules.format.renderedCallback();
16652 Format.prototype.formatValue =
function (cell) {
16653 var component = cell.getComponent(),
16654 params = typeof cell.column.modules.format.params ===
"function" ? cell.column.modules.format.params(component) : cell.column.modules.format.params;
16656 function onRendered(callback) {
16657 if (!cell.modules.format) {
16658 cell.modules.format = {};
16661 cell.modules.format.renderedCallback = callback;
16664 return cell.column.modules.format.formatter.call(
this, component, params, onRendered);
16667 Format.prototype.sanitizeHTML =
function (value) {
16680 return String(value).replace(/[&<>
"'`=\/]/g, function (s) {
16681 return entityMap[s];
16688 Format.prototype.emptyToSpace = function (value) {
16689 return value === null || typeof value === "undefined
" ? "
" : value;
16692 //get formatter for cell
16693 Format.prototype.getFormatter = function (formatter) {
16696 switch (typeof formatter === 'undefined' ? 'undefined' : _typeof(formatter)) {
16698 if (this.formatters[formatter]) {
16699 formatter = this.formatters[formatter];
16701 console.warn("Formatter Error - No such formatter found:
", formatter);
16702 formatter = this.formatters.plaintext;
16707 formatter = formatter;
16711 formatter = this.formatters.plaintext;
16718 //default data formatters
16719 Format.prototype.formatters = {
16721 plaintext: function plaintext(cell, formatterParams, onRendered) {
16722 return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
16726 html: function html(cell, formatterParams, onRendered) {
16727 return cell.getValue();
16730 //multiline text area
16731 textarea: function textarea(cell, formatterParams, onRendered) {
16732 cell.getElement().style.whiteSpace = "pre-wrap
";
16733 return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
16736 //currency formatting
16737 money: function money(cell, formatterParams, onRendered) {
16738 var floatVal = parseFloat(cell.getValue()),
16744 var decimalSym = formatterParams.decimal || ".
";
16745 var thousandSym = formatterParams.thousand || ",
";
16746 var symbol = formatterParams.symbol || "";
16747 var after = !!formatterParams.symbolAfter;
16748 var precision = typeof formatterParams.precision !== "undefined
" ? formatterParams.precision : 2;
16750 if (isNaN(floatVal)) {
16751 return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
16754 number = precision !== false ? floatVal.toFixed(precision) : floatVal;
16755 number = String(number).split(".
");
16757 integer = number[0];
16758 decimal = number.length > 1 ? decimalSym + number[1] : "";
16760 rgx = /(\d+)(\d{3})/;
16762 while (rgx.test(integer)) {
16763 integer = integer.replace(rgx, "$1
" + thousandSym + "$2
");
16766 return after ? integer + decimal + symbol : symbol + integer + decimal;
16769 //clickable anchor tag
16770 link: function link(cell, formatterParams, onRendered) {
16771 var value = cell.getValue(),
16772 urlPrefix = formatterParams.urlPrefix || "",
16773 download = formatterParams.download,
16775 el = document.createElement("a
"),
16778 if (formatterParams.labelField) {
16779 data = cell.getData();
16780 label = data[formatterParams.labelField];
16783 if (formatterParams.label) {
16784 switch (_typeof(formatterParams.label)) {
16786 label = formatterParams.label;
16790 label = formatterParams.label(cell);
16796 if (formatterParams.urlField) {
16797 data = cell.getData();
16798 value = data[formatterParams.urlField];
16801 if (formatterParams.url) {
16802 switch (_typeof(formatterParams.url)) {
16804 value = formatterParams.url;
16808 value = formatterParams.url(cell);
16813 el.setAttribute("href
", urlPrefix + value);
16815 if (formatterParams.target) {
16816 el.setAttribute("target
", formatterParams.target);
16819 if (formatterParams.download) {
16821 if (typeof download == "function") {
16822 download = download(cell);
16824 download = download === true ? "" : download;
16827 el.setAttribute("download
", download);
16830 el.innerHTML = this.emptyToSpace(this.sanitizeHTML(label));
16839 image: function image(cell, formatterParams, onRendered) {
16840 var el = document.createElement("img
");
16841 el.setAttribute("src
", cell.getValue());
16843 switch (_typeof(formatterParams.height)) {
16845 el.style.height = formatterParams.height + "px
";
16849 el.style.height = formatterParams.height;
16853 switch (_typeof(formatterParams.width)) {
16855 el.style.width = formatterParams.width + "px
";
16859 el.style.width = formatterParams.width;
16863 el.addEventListener("load
", function () {
16864 cell.getRow().normalizeHeight();
16871 tickCross: function tickCross(cell, formatterParams, onRendered) {
16872 var value = cell.getValue(),
16873 element = cell.getElement(),
16874 empty = formatterParams.allowEmpty,
16875 truthy = formatterParams.allowTruthy,
16876 tick = typeof formatterParams.tickElement !== "undefined
" ? formatterParams.tickElement : '<svg enable-background="new 0 0 24 24
" height="14
" width="14
" viewBox="0 0 24 24
" xml:space="preserve
" ><path fill="#2DC214
" clip-rule="evenodd
" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z
" fill-rule="evenodd
"/></svg>',
16877 cross = typeof formatterParams.crossElement !== "undefined
" ? formatterParams.crossElement : '<svg enable-background="new 0 0 24 24
" height="14
" width="14
" viewBox="0 0 24 24
" xml:space="preserve
" ><path fill="#CE1515
" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z
"/></svg>';
16879 if (truthy && value || value === true || value === "true" || value === "True
" || value === 1 || value === "1
") {
16880 element.setAttribute("aria-checked
", true);
16883 if (empty && (value === "null
" || value === "" || value === null || typeof value === "undefined
")) {
16884 element.setAttribute("aria-checked
", "mixed
");
16887 element.setAttribute("aria-checked
", false);
16888 return cross || "";
16893 datetime: function datetime(cell, formatterParams, onRendered) {
16894 var inputFormat = formatterParams.inputFormat || "YYYY-MM-DD hh:mm:ss
";
16895 var outputFormat = formatterParams.outputFormat || "DD/MM/YYYY hh:mm:ss
";
16896 var invalid = typeof formatterParams.invalidPlaceholder !== "undefined
" ? formatterParams.invalidPlaceholder : "";
16897 var value = cell.getValue();
16899 var newDatetime = moment(value, inputFormat);
16901 if (newDatetime.isValid()) {
16902 return newDatetime.format(outputFormat);
16905 if (invalid === true) {
16907 } else if (typeof invalid === "function") {
16908 return invalid(value);
16915 datetimediff: function datetime(cell, formatterParams, onRendered) {
16916 var inputFormat = formatterParams.inputFormat || "YYYY-MM-DD hh:mm:ss
";
16917 var invalid = typeof formatterParams.invalidPlaceholder !== "undefined
" ? formatterParams.invalidPlaceholder : "";
16918 var suffix = typeof formatterParams.suffix !== "undefined
" ? formatterParams.suffix : false;
16919 var unit = typeof formatterParams.unit !== "undefined
" ? formatterParams.unit : undefined;
16920 var humanize = typeof formatterParams.humanize !== "undefined
" ? formatterParams.humanize : false;
16921 var date = typeof formatterParams.date !== "undefined
" ? formatterParams.date : moment();
16922 var value = cell.getValue();
16924 var newDatetime = moment(value, inputFormat);
16926 if (newDatetime.isValid()) {
16928 return moment.duration(newDatetime.diff(date)).humanize(suffix);
16930 return newDatetime.diff(date, unit) + (suffix ? " " + suffix : "");
16934 if (invalid === true) {
16936 } else if (typeof invalid === "function") {
16937 return invalid(value);
16945 lookup: function lookup(cell, formatterParams, onRendered) {
16946 var value = cell.getValue();
16948 if (typeof formatterParams[value] === "undefined
") {
16949 console.warn('Missing display value for ' + value);
16953 return formatterParams[value];
16957 star: function star(cell, formatterParams, onRendered) {
16958 var value = cell.getValue(),
16959 element = cell.getElement(),
16960 maxStars = formatterParams && formatterParams.stars ? formatterParams.stars : 5,
16961 stars = document.createElement("span
"),
16962 star = document.createElementNS('http://www.w3.org/2000/svg', "svg
"),
16963 starActive = '<polygon fill="#FFEA00
" stroke="#C1AB60
" stroke-width="37.6152
" stroke-linecap="round
" stroke-linejoin="round
" stroke-miterlimit="10
" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919
"/>',
16964 starInactive = '<polygon fill="#D2D2D2
" stroke="#686868
" stroke-width="37.6152
" stroke-linecap="round
" stroke-linejoin="round
" stroke-miterlimit="10
" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919
"/>';
16966 //style stars holder
16967 stars.style.verticalAlign = "middle
";
16970 star.setAttribute("width
", "14
");
16971 star.setAttribute("height
", "14
");
16972 star.setAttribute("viewBox
", "0 0 512 512
");
16973 star.setAttribute("xml:space
", "preserve
");
16974 star.style.padding = "0 1px
";
16976 value = value && !isNaN(value) ? parseInt(value) : 0;
16978 value = Math.max(0, Math.min(value, maxStars));
16980 for (var i = 1; i <= maxStars; i++) {
16981 var nextStar = star.cloneNode(true);
16982 nextStar.innerHTML = i <= value ? starActive : starInactive;
16984 stars.appendChild(nextStar);
16987 element.style.whiteSpace = "nowrap
";
16988 element.style.overflow = "hidden
";
16989 element.style.textOverflow = "ellipsis
";
16991 element.setAttribute("aria-label
", value);
16996 traffic: function traffic(cell, formatterParams, onRendered) {
16997 var value = this.sanitizeHTML(cell.getValue()) || 0,
16998 el = document.createElement("span
"),
16999 max = formatterParams && formatterParams.max ? formatterParams.max : 100,
17000 min = formatterParams && formatterParams.min ? formatterParams.min : 0,
17001 colors = formatterParams && typeof formatterParams.color !== "undefined
" ? formatterParams.color : ["red
", "orange
", "green
"],
17006 if (isNaN(value) || typeof cell.getValue() === "undefined
") {
17010 el.classList.add("tabulator-traffic-light
");
17012 //make sure value is in range
17013 percentValue = parseFloat(value) <= max ? parseFloat(value) : max;
17014 percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;
17016 //workout percentage
17017 percent = (max - min) / 100;
17018 percentValue = Math.round((percentValue - min) / percent);
17021 switch (typeof colors === 'undefined' ? 'undefined' : _typeof(colors)) {
17026 color = colors(value);
17029 if (Array.isArray(colors)) {
17030 var unit = 100 / colors.length;
17031 var index = Math.floor(percentValue / unit);
17033 index = Math.min(index, colors.length - 1);
17034 index = Math.max(index, 0);
17035 color = colors[index];
17040 el.style.backgroundColor = color;
17046 progress: function progress(cell, formatterParams, onRendered) {
17048 var value = this.sanitizeHTML(cell.getValue()) || 0,
17049 element = cell.getElement(),
17050 max = formatterParams && formatterParams.max ? formatterParams.max : 100,
17051 min = formatterParams && formatterParams.min ? formatterParams.min : 0,
17052 legendAlign = formatterParams && formatterParams.legendAlign ? formatterParams.legendAlign : "center
",
17063 //make sure value is in range
17064 percentValue = parseFloat(value) <= max ? parseFloat(value) : max;
17065 percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;
17067 //workout percentage
17068 percent = (max - min) / 100;
17069 percentValue = Math.round((percentValue - min) / percent);
17072 switch (_typeof(formatterParams.color)) {
17074 color = formatterParams.color;
17077 color = formatterParams.color(value);
17080 if (Array.isArray(formatterParams.color)) {
17081 var unit = 100 / formatterParams.color.length;
17082 var index = Math.floor(percentValue / unit);
17084 index = Math.min(index, formatterParams.color.length - 1);
17085 index = Math.max(index, 0);
17086 color = formatterParams.color[index];
17094 switch (_typeof(formatterParams.legend)) {
17096 legend = formatterParams.legend;
17099 legend = formatterParams.legend(value);
17109 switch (_typeof(formatterParams.legendColor)) {
17111 legendColor = formatterParams.legendColor;
17114 legendColor = formatterParams.legendColor(value);
17117 if (Array.isArray(formatterParams.legendColor)) {
17118 var unit = 100 / formatterParams.legendColor.length;
17119 var index = Math.floor(percentValue / unit);
17121 index = Math.min(index, formatterParams.legendColor.length - 1);
17122 index = Math.max(index, 0);
17123 legendColor = formatterParams.legendColor[index];
17127 legendColor = "#000
";
17130 element.style.minWidth = "30px
";
17131 element.style.position = "relative
";
17133 element.setAttribute("aria-label
", percentValue);
17135 var barEl = document.createElement("div
");
17136 barEl.style.display = "inline-block
";
17137 barEl.style.position = "relative
";
17138 barEl.style.width = percentValue + "%
";
17139 barEl.style.backgroundColor = color;
17140 barEl.style.height = "100%
";
17142 barEl.setAttribute('data-max', max);
17143 barEl.setAttribute('data-min', min);
17146 var legendEl = document.createElement("div
");
17147 legendEl.style.position = "absolute
";
17148 legendEl.style.top = "4px
";
17149 legendEl.style.left = 0;
17150 legendEl.style.textAlign = legendAlign;
17151 legendEl.style.width = "100%
";
17152 legendEl.style.color = legendColor;
17153 legendEl.innerHTML = legend;
17156 onRendered(function () {
17157 element.appendChild(barEl);
17160 element.appendChild(legendEl);
17168 color: function color(cell, formatterParams, onRendered) {
17169 cell.getElement().style.backgroundColor = this.sanitizeHTML(cell.getValue());
17174 buttonTick: function buttonTick(cell, formatterParams, onRendered) {
17175 return '<svg enable-background="new 0 0 24 24
" height="14
" width="14
" viewBox="0 0 24 24
" xml:space="preserve
" ><path fill="#2DC214
" clip-rule="evenodd
" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z
" fill-rule="evenodd
"/></svg>';
17179 buttonCross: function buttonCross(cell, formatterParams, onRendered) {
17180 return '<svg enable-background="new 0 0 24 24
" height="14
" width="14
" viewBox="0 0 24 24
" xml:space="preserve
" ><path fill="#CE1515
" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z
"/></svg>';
17183 //current row number
17184 rownum: function rownum(cell, formatterParams, onRendered) {
17185 return this.table.rowManager.activeRows.indexOf(cell.getRow()._getSelf()) + 1;
17189 handle: function handle(cell, formatterParams, onRendered) {
17190 cell.getElement().classList.add("tabulator-row-handle
");
17191 return "<div
class=
'tabulator-row-handle-box'><div
class=
'tabulator-row-handle-bar'></div><div
class=
'tabulator-row-handle-bar'></div><div
class=
'tabulator-row-handle-bar'></div></div>
";
17194 responsiveCollapse: function responsiveCollapse(cell, formatterParams, onRendered) {
17197 el = document.createElement("div
"),
17198 config = cell.getRow()._row.modules.responsiveLayout;
17200 el.classList.add("tabulator-responsive-collapse-toggle
");
17201 el.innerHTML = "<span
class=
'tabulator-responsive-collapse-toggle-open'>+</span><span
class=
'tabulator-responsive-collapse-toggle-close'>-</span>
";
17203 cell.getElement().classList.add("tabulator-row-handle
");
17205 function toggleList(isOpen) {
17206 var collapseEl = config.element;
17208 config.open = isOpen;
17213 el.classList.add("open
");
17214 collapseEl.style.display = '';
17216 el.classList.remove("open
");
17217 collapseEl.style.display = 'none';
17222 el.addEventListener("click
", function (e) {
17223 e.stopImmediatePropagation();
17224 toggleList(!config.open);
17227 toggleList(config.open);
17232 rowSelection: function rowSelection(cell) {
17233 var _this48 = this;
17235 var checkbox = document.createElement("input
");
17237 checkbox.type = 'checkbox';
17239 if (this.table.modExists("selectRow
", true)) {
17241 checkbox.addEventListener("click
", function (e) {
17242 e.stopPropagation();
17245 if (typeof cell.getRow == 'function') {
17246 var row = cell.getRow();
17248 checkbox.addEventListener("change
", function (e) {
17249 row.toggleSelect();
17252 checkbox.checked = row.isSelected();
17253 this.table.modules.selectRow.registerRowSelectCheckbox(row, checkbox);
17255 checkbox.addEventListener("change
", function (e) {
17256 if (_this48.table.modules.selectRow.selectedRows.length) {
17257 _this48.table.deselectRow();
17259 _this48.table.selectRow();
17263 this.table.modules.selectRow.registerHeaderSelectCheckbox(checkbox);
17270 Tabulator.prototype.registerModule("format
", Format);
17272 var FrozenColumns = function FrozenColumns(table) {
17273 this.table = table; //hold Tabulator object
17274 this.leftColumns = [];
17275 this.rightColumns = [];
17276 this.leftMargin = 0;
17277 this.rightMargin = 0;
17278 this.rightPadding = 0;
17279 this.initializationMode = "left
";
17280 this.active = false;
17281 this.scrollEndTimer = false;
17284 //reset initial state
17285 FrozenColumns.prototype.reset = function () {
17286 this.initializationMode = "left
";
17287 this.leftColumns = [];
17288 this.rightColumns = [];
17289 this.leftMargin = 0;
17290 this.rightMargin = 0;
17291 this.rightMargin = 0;
17292 this.active = false;
17294 this.table.columnManager.headersElement.style.marginLeft = 0;
17295 this.table.columnManager.element.style.paddingRight = 0;
17298 //initialize specific column
17299 FrozenColumns.prototype.initializeColumn = function (column) {
17300 var config = { margin: 0, edge: false };
17302 if (column.definition.frozen) {
17304 if (!column.parent.isGroup) {
17306 if (!column.isGroup) {
17307 config.position = this.initializationMode;
17309 if (this.initializationMode == "left
") {
17310 this.leftColumns.push(column);
17312 this.rightColumns.unshift(column);
17315 this.active = true;
17317 column.modules.frozen = config;
17319 console.warn("Frozen Column Error - Column Groups cannot be frozen
");
17322 console.warn("Frozen Column Error - Grouped columns cannot be frozen
");
17325 this.initializationMode = "right
";
17329 //quick layout to smooth horizontal scrolling
17330 FrozenColumns.prototype.scrollHorizontal = function () {
17331 var _this49 = this;
17336 clearTimeout(this.scrollEndTimer);
17338 //layout all rows after scroll is complete
17339 this.scrollEndTimer = setTimeout(function () {
17343 rows = this.table.rowManager.getVisibleRows();
17345 this.calcMargins();
17347 this.layoutColumnPosition();
17349 this.layoutCalcRows();
17351 rows.forEach(function (row) {
17352 if (row.type === "row
") {
17353 _this49.layoutRow(row);
17357 this.table.rowManager.tableElement.style.marginRight = this.rightMargin;
17361 //calculate margins for rows
17362 FrozenColumns.prototype.calcMargins = function () {
17363 this.leftMargin = this._calcSpace(this.leftColumns, this.leftColumns.length) + "px
";
17364 this.table.columnManager.headersElement.style.marginLeft = this.leftMargin;
17366 this.rightMargin = this._calcSpace(this.rightColumns, this.rightColumns.length) + "px
";
17367 this.table.columnManager.element.style.paddingRight = this.rightMargin;
17369 //calculate right frozen columns
17370 this.rightPadding = this.table.rowManager.element.clientWidth + this.table.columnManager.scrollLeft;
17373 //layout calculation rows
17374 FrozenColumns.prototype.layoutCalcRows = function () {
17375 if (this.table.modExists("columnCalcs
")) {
17376 if (this.table.modules.columnCalcs.topInitialized && this.table.modules.columnCalcs.topRow) {
17377 this.layoutRow(this.table.modules.columnCalcs.topRow);
17379 if (this.table.modules.columnCalcs.botInitialized && this.table.modules.columnCalcs.botRow) {
17380 this.layoutRow(this.table.modules.columnCalcs.botRow);
17385 //calculate column positions and layout headers
17386 FrozenColumns.prototype.layoutColumnPosition = function (allCells) {
17387 var _this50 = this;
17389 this.leftColumns.forEach(function (column, i) {
17390 column.modules.frozen.margin = _this50._calcSpace(_this50.leftColumns, i) + _this50.table.columnManager.scrollLeft + "px
";
17392 if (i == _this50.leftColumns.length - 1) {
17393 column.modules.frozen.edge = true;
17395 column.modules.frozen.edge = false;
17398 _this50.layoutElement(column.getElement(), column);
17401 column.cells.forEach(function (cell) {
17402 _this50.layoutElement(cell.getElement(), column);
17407 this.rightColumns.forEach(function (column, i) {
17408 column.modules.frozen.margin = _this50.rightPadding - _this50._calcSpace(_this50.rightColumns, i + 1) + "px
";
17410 if (i == _this50.rightColumns.length - 1) {
17411 column.modules.frozen.edge = true;
17413 column.modules.frozen.edge = false;
17416 _this50.layoutElement(column.getElement(), column);
17419 column.cells.forEach(function (cell) {
17420 _this50.layoutElement(cell.getElement(), column);
17426 //layout columns appropropriatly
17427 FrozenColumns.prototype.layout = function () {
17433 //calculate row padding
17434 this.calcMargins();
17436 // self.table.rowManager.activeRows.forEach(function(row){
17437 // self.layoutRow(row);
17440 // if(self.table.options.dataTree){
17441 self.table.rowManager.getDisplayRows().forEach(function (row) {
17442 if (row.type === "row
") {
17443 self.layoutRow(row);
17448 this.layoutCalcRows();
17450 //calculate left columns
17451 this.layoutColumnPosition(true);
17453 // if(tableHolder.scrollHeight > tableHolder.clientHeight){
17454 // rightMargin -= tableHolder.offsetWidth - tableHolder.clientWidth;
17457 this.table.rowManager.tableElement.style.marginRight = this.rightMargin;
17461 FrozenColumns.prototype.layoutRow = function (row) {
17462 var _this51 = this;
17464 var rowEl = row.getElement();
17466 rowEl.style.paddingLeft = this.leftMargin;
17467 // rowEl.style.paddingRight = this.rightMargin + "px
";
17469 this.leftColumns.forEach(function (column) {
17470 var cell = row.getCell(column);
17473 _this51.layoutElement(cell.getElement(), column);
17477 this.rightColumns.forEach(function (column) {
17478 var cell = row.getCell(column);
17481 _this51.layoutElement(cell.getElement(), column);
17486 FrozenColumns.prototype.layoutElement = function (element, column) {
17488 if (column.modules.frozen) {
17489 element.style.position = "absolute
";
17490 element.style.left = column.modules.frozen.margin;
17492 element.classList.add("tabulator-frozen
");
17494 if (column.modules.frozen.edge) {
17495 element.classList.add("tabulator-frozen-
" + column.modules.frozen.position);
17500 FrozenColumns.prototype._calcSpace = function (columns, index) {
17503 for (var i = 0; i < index; i++) {
17504 if (columns[i].visible) {
17505 width += columns[i].getWidth();
17512 Tabulator.prototype.registerModule("frozenColumns
", FrozenColumns);
17513 var FrozenRows = function FrozenRows(table) {
17514 this.table = table; //hold Tabulator object
17515 this.topElement = document.createElement("div
");
17517 this.displayIndex = 0; //index in display pipeline
17520 FrozenRows.prototype.initialize = function () {
17523 this.topElement.classList.add("tabulator-frozen-rows-holder
");
17525 // this.table.columnManager.element.append(this.topElement);
17526 this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
17529 FrozenRows.prototype.setDisplayIndex = function (index) {
17530 this.displayIndex = index;
17533 FrozenRows.prototype.getDisplayIndex = function () {
17534 return this.displayIndex;
17537 FrozenRows.prototype.isFrozen = function () {
17538 return !!this.rows.length;
17541 //filter frozen rows out of display data
17542 FrozenRows.prototype.getRows = function (rows) {
17545 output = rows.slice(0);
17547 this.rows.forEach(function (row) {
17548 var index = output.indexOf(row);
17551 output.splice(index, 1);
17558 FrozenRows.prototype.freezeRow = function (row) {
17559 if (!row.modules.frozen) {
17560 row.modules.frozen = true;
17561 this.topElement.appendChild(row.getElement());
17563 row.normalizeHeight();
17564 this.table.rowManager.adjustTableSize();
17566 this.rows.push(row);
17568 this.table.rowManager.refreshActiveData("display
");
17572 console.warn("Freeze Error - Row is already frozen
");
17576 FrozenRows.prototype.unfreezeRow = function (row) {
17577 var index = this.rows.indexOf(row);
17579 if (row.modules.frozen) {
17581 row.modules.frozen = false;
17583 var rowEl = row.getElement();
17584 rowEl.parentNode.removeChild(rowEl);
17586 this.table.rowManager.adjustTableSize();
17588 this.rows.splice(index, 1);
17590 this.table.rowManager.refreshActiveData("display
");
17592 if (this.rows.length) {
17596 console.warn("Freeze Error - Row is already unfrozen
");
17600 FrozenRows.prototype.styleRows = function (row) {
17603 this.rows.forEach(function (row, i) {
17604 self.table.rowManager.styleRow(row, i);
17608 Tabulator.prototype.registerModule("frozenRows
", FrozenRows);
17610 //public group object
17611 var GroupComponent = function GroupComponent(group) {
17612 this._group = group;
17613 this.type = "GroupComponent
";
17616 GroupComponent.prototype.getKey = function () {
17617 return this._group.key;
17620 GroupComponent.prototype.getField = function () {
17621 return this._group.field;
17624 GroupComponent.prototype.getElement = function () {
17625 return this._group.element;
17628 GroupComponent.prototype.getRows = function () {
17629 return this._group.getRows(true);
17632 GroupComponent.prototype.getSubGroups = function () {
17633 return this._group.getSubGroups(true);
17636 GroupComponent.prototype.getParentGroup = function () {
17637 return this._group.parent ? this._group.parent.getComponent() : false;
17640 GroupComponent.prototype.getVisibility = function () {
17641 return this._group.visible;
17644 GroupComponent.prototype.show = function () {
17645 this._group.show();
17648 GroupComponent.prototype.hide = function () {
17649 this._group.hide();
17652 GroupComponent.prototype.toggle = function () {
17653 this._group.toggleVisibility();
17656 GroupComponent.prototype._getSelf = function () {
17657 return this._group;
17660 GroupComponent.prototype.getTable = function () {
17661 return this._group.groupManager.table;
17668 var Group = function Group(groupManager, parent, level, key, field, generator, oldGroup) {
17670 this.groupManager = groupManager;
17671 this.parent = parent;
17673 this.level = level;
17674 this.field = field;
17675 this.hasSubGroups = level < groupManager.groupIDLookups.length - 1;
17676 this.addRow = this.hasSubGroups ? this._addRowToGroup : this._addRow;
17677 this.type = "group
"; //type of element
17678 this.old = oldGroup;
17681 this.groupList = [];
17682 this.generator = generator;
17683 this.elementContents = false;
17685 this.outerHeight = 0;
17686 this.initialized = false;
17688 this.initialized = false;
17690 this.arrowElement = false;
17692 this.visible = oldGroup ? oldGroup.visible : typeof groupManager.startOpen[level] !== "undefined
" ? groupManager.startOpen[level] : groupManager.startOpen[0];
17694 this.createElements();
17695 this.addBindings();
17697 this.createValueGroups();
17700 Group.prototype.wipe = function () {
17701 if (this.groupList.length) {
17702 this.groupList.forEach(function (group) {
17706 this.element = false;
17707 this.arrowElement = false;
17708 this.elementContents = false;
17712 Group.prototype.createElements = function () {
17713 var arrow = document.createElement("div
");
17714 arrow.classList.add("tabulator-arrow
");
17716 this.element = document.createElement("div
");
17717 this.element.classList.add("tabulator-row
");
17718 this.element.classList.add("tabulator-group
");
17719 this.element.classList.add("tabulator-group-level-
" + this.level);
17720 this.element.setAttribute("role
", "rowgroup
");
17722 this.arrowElement = document.createElement("div
");
17723 this.arrowElement.classList.add("tabulator-group-toggle
");
17724 this.arrowElement.appendChild(arrow);
17726 //setup movable rows
17727 if (this.groupManager.table.options.movableRows !== false && this.groupManager.table.modExists("moveRow
")) {
17728 this.groupManager.table.modules.moveRow.initializeGroupHeader(this);
17732 Group.prototype.createValueGroups = function () {
17733 var _this52 = this;
17735 var level = this.level + 1;
17736 if (this.groupManager.allowedValues && this.groupManager.allowedValues[level]) {
17737 this.groupManager.allowedValues[level].forEach(function (value) {
17738 _this52._createGroup(value, level);
17743 Group.prototype.addBindings = function () {
17750 //handle group click events
17751 if (self.groupManager.table.options.groupClick) {
17752 self.element.addEventListener("click
", function (e) {
17753 self.groupManager.table.options.groupClick.call(self.groupManager.table, e, self.getComponent());
17757 if (self.groupManager.table.options.groupDblClick) {
17758 self.element.addEventListener("dblclick
", function (e) {
17759 self.groupManager.table.options.groupDblClick.call(self.groupManager.table, e, self.getComponent());
17763 if (self.groupManager.table.options.groupContext) {
17764 self.element.addEventListener("contextmenu
", function (e) {
17765 self.groupManager.table.options.groupContext.call(self.groupManager.table, e, self.getComponent());
17769 if (self.groupManager.table.options.groupTap) {
17773 self.element.addEventListener("touchstart
", function (e) {
17775 }, { passive: true });
17777 self.element.addEventListener("touchend
", function (e) {
17779 self.groupManager.table.options.groupTap(e, self.getComponent());
17786 if (self.groupManager.table.options.groupDblTap) {
17790 self.element.addEventListener("touchend
", function (e) {
17793 clearTimeout(dblTap);
17796 self.groupManager.table.options.groupDblTap(e, self.getComponent());
17799 dblTap = setTimeout(function () {
17800 clearTimeout(dblTap);
17807 if (self.groupManager.table.options.groupTapHold) {
17811 self.element.addEventListener("touchstart
", function (e) {
17812 clearTimeout(tapHold);
17814 tapHold = setTimeout(function () {
17815 clearTimeout(tapHold);
17818 self.groupManager.table.options.groupTapHold(e, self.getComponent());
17820 }, { passive: true });
17822 self.element.addEventListener("touchend
", function (e) {
17823 clearTimeout(tapHold);
17828 if (self.groupManager.table.options.groupToggleElement) {
17829 toggleElement = self.groupManager.table.options.groupToggleElement == "arrow
" ? self.arrowElement : self.element;
17831 toggleElement.addEventListener("click
", function (e) {
17832 e.stopPropagation();
17833 e.stopImmediatePropagation();
17834 self.toggleVisibility();
17839 Group.prototype._createGroup = function (groupID, level) {
17840 var groupKey = level + "_
" + groupID;
17841 var group = new Group(this.groupManager, this, level, groupID, this.groupManager.groupIDLookups[level].field, this.groupManager.headerGenerator[level] || this.groupManager.headerGenerator[0], this.old ? this.old.groups[groupKey] : false);
17843 this.groups[groupKey] = group;
17844 this.groupList.push(group);
17847 Group.prototype._addRowToGroup = function (row) {
17849 var level = this.level + 1;
17851 if (this.hasSubGroups) {
17852 var groupID = this.groupManager.groupIDLookups[level].func(row.getData()),
17853 groupKey = level + "_
" + groupID;
17855 if (this.groupManager.allowedValues && this.groupManager.allowedValues[level]) {
17856 if (this.groups[groupKey]) {
17857 this.groups[groupKey].addRow(row);
17860 if (!this.groups[groupKey]) {
17861 this._createGroup(groupID, level);
17864 this.groups[groupKey].addRow(row);
17869 Group.prototype._addRow = function (row) {
17870 this.rows.push(row);
17871 row.modules.group = this;
17874 Group.prototype.insertRow = function (row, to, after) {
17875 var data = this.conformRowData({});
17877 row.updateData(data);
17879 var toIndex = this.rows.indexOf(to);
17881 if (toIndex > -1) {
17883 this.rows.splice(toIndex + 1, 0, row);
17885 this.rows.splice(toIndex, 0, row);
17889 this.rows.push(row);
17891 this.rows.unshift(row);
17895 row.modules.group = this;
17897 this.generateGroupHeaderContents();
17899 if (this.groupManager.table.modExists("columnCalcs
") && this.groupManager.table.options.columnCalcs != "table
") {
17900 this.groupManager.table.modules.columnCalcs.recalcGroup(this);
17903 this.groupManager.updateGroupRows(true);
17906 Group.prototype.scrollHeader = function (left) {
17907 this.arrowElement.style.marginLeft = left;
17909 this.groupList.forEach(function (child) {
17910 child.scrollHeader(left);
17914 Group.prototype.getRowIndex = function (row) {};
17916 //update row data to match grouping contraints
17917 Group.prototype.conformRowData = function (data) {
17919 data[this.field] = this.key;
17921 console.warn("Data Conforming Error - Cannot conform row data to match
new group as groupBy is a
function");
17925 data = this.parent.conformRowData(data);
17931 Group.prototype.removeRow = function (row) {
17932 var index = this.rows.indexOf(row);
17933 var el = row.getElement();
17936 this.rows.splice(index, 1);
17939 if (!this.groupManager.table.options.groupValues && !this.rows.length) {
17941 this.parent.removeGroup(this);
17943 this.groupManager.removeGroup(this);
17946 this.groupManager.updateGroupRows(true);
17949 if (el.parentNode) {
17950 el.parentNode.removeChild(el);
17953 this.generateGroupHeaderContents();
17955 if (this.groupManager.table.modExists("columnCalcs
") && this.groupManager.table.options.columnCalcs != "table
") {
17956 this.groupManager.table.modules.columnCalcs.recalcGroup(this);
17961 Group.prototype.removeGroup = function (group) {
17962 var groupKey = group.level + "_
" + group.key,
17965 if (this.groups[groupKey]) {
17966 delete this.groups[groupKey];
17968 index = this.groupList.indexOf(group);
17971 this.groupList.splice(index, 1);
17974 if (!this.groupList.length) {
17976 this.parent.removeGroup(this);
17978 this.groupManager.removeGroup(this);
17984 Group.prototype.getHeadersAndRows = function (noCalc) {
17991 if (this.visible) {
17992 if (this.groupList.length) {
17993 this.groupList.forEach(function (group) {
17994 output = output.concat(group.getHeadersAndRows(noCalc));
17997 if (!noCalc && this.groupManager.table.options.columnCalcs != "table
" && this.groupManager.table.modExists("columnCalcs
") && this.groupManager.table.modules.columnCalcs.hasTopCalcs()) {
17998 if (this.calcs.top) {
17999 this.calcs.top.detachElement();
18000 this.calcs.top.deleteCells();
18003 this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);
18004 output.push(this.calcs.top);
18007 output = output.concat(this.rows);
18009 if (!noCalc && this.groupManager.table.options.columnCalcs != "table
" && this.groupManager.table.modExists("columnCalcs
") && this.groupManager.table.modules.columnCalcs.hasBottomCalcs()) {
18010 if (this.calcs.bottom) {
18011 this.calcs.bottom.detachElement();
18012 this.calcs.bottom.deleteCells();
18015 this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);
18016 output.push(this.calcs.bottom);
18020 if (!this.groupList.length && this.groupManager.table.options.columnCalcs != "table
") {
18022 if (this.groupManager.table.modExists("columnCalcs
")) {
18024 if (!noCalc && this.groupManager.table.modules.columnCalcs.hasTopCalcs()) {
18025 if (this.calcs.top) {
18026 this.calcs.top.detachElement();
18027 this.calcs.top.deleteCells();
18030 if (this.groupManager.table.options.groupClosedShowCalcs) {
18031 this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);
18032 output.push(this.calcs.top);
18036 if (!noCalc && this.groupManager.table.modules.columnCalcs.hasBottomCalcs()) {
18037 if (this.calcs.bottom) {
18038 this.calcs.bottom.detachElement();
18039 this.calcs.bottom.deleteCells();
18042 if (this.groupManager.table.options.groupClosedShowCalcs) {
18043 this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);
18044 output.push(this.calcs.bottom);
18054 Group.prototype.getData = function (visible, transform) {
18060 if (!visible || visible && this.visible) {
18061 this.rows.forEach(function (row) {
18062 output.push(row.getData(transform || "data
"));
18069 // Group.prototype.getRows = function(){
18072 // return this.visible ? this.rows : [];
18075 Group.prototype.getRowCount = function () {
18078 if (this.groupList.length) {
18079 this.groupList.forEach(function (group) {
18080 count += group.getRowCount();
18083 count = this.rows.length;
18088 Group.prototype.toggleVisibility = function () {
18089 if (this.visible) {
18096 Group.prototype.hide = function () {
18097 this.visible = false;
18099 if (this.groupManager.table.rowManager.getRenderMode() == "classic
" && !this.groupManager.table.options.pagination) {
18101 this.element.classList.remove("tabulator-group-visible
");
18103 if (this.groupList.length) {
18104 this.groupList.forEach(function (group) {
18106 var rows = group.getHeadersAndRows();
18108 rows.forEach(function (row) {
18109 row.detachElement();
18113 this.rows.forEach(function (row) {
18114 var rowEl = row.getElement();
18115 rowEl.parentNode.removeChild(rowEl);
18119 this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
18121 this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
18123 this.groupManager.updateGroupRows(true);
18126 this.groupManager.table.options.groupVisibilityChanged.call(this.table, this.getComponent(), false);
18129 Group.prototype.show = function () {
18132 self.visible = true;
18134 if (this.groupManager.table.rowManager.getRenderMode() == "classic
" && !this.groupManager.table.options.pagination) {
18136 this.element.classList.add("tabulator-group-visible
");
18138 var prev = self.getElement();
18140 if (this.groupList.length) {
18141 this.groupList.forEach(function (group) {
18142 var rows = group.getHeadersAndRows();
18144 rows.forEach(function (row) {
18145 var rowEl = row.getElement();
18146 prev.parentNode.insertBefore(rowEl, prev.nextSibling);
18152 self.rows.forEach(function (row) {
18153 var rowEl = row.getElement();
18154 prev.parentNode.insertBefore(rowEl, prev.nextSibling);
18160 this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
18162 this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
18164 this.groupManager.updateGroupRows(true);
18167 this.groupManager.table.options.groupVisibilityChanged.call(this.table, this.getComponent(), true);
18170 Group.prototype._visSet = function () {
18173 if (typeof this.visible == "function") {
18175 this.rows.forEach(function (row) {
18176 data.push(row.getData());
18179 this.visible = this.visible(this.key, this.getRowCount(), data, this.getComponent());
18183 Group.prototype.getRowGroup = function (row) {
18185 if (this.groupList.length) {
18186 this.groupList.forEach(function (group) {
18187 var result = group.getRowGroup(row);
18194 if (this.rows.find(function (item) {
18195 return item === row;
18204 Group.prototype.getSubGroups = function (component) {
18207 this.groupList.forEach(function (child) {
18208 output.push(component ? child.getComponent() : child);
18214 Group.prototype.getRows = function (compoment) {
18217 this.rows.forEach(function (row) {
18218 output.push(compoment ? row.getComponent() : row);
18224 Group.prototype.generateGroupHeaderContents = function () {
18227 this.rows.forEach(function (row) {
18228 data.push(row.getData());
18231 this.elementContents = this.generator(this.key, this.getRowCount(), data, this.getComponent());
18233 while (this.element.firstChild) {
18234 this.element.removeChild(this.element.firstChild);
18235 }if (typeof this.elementContents === "string") {
18236 this.element.innerHTML = this.elementContents;
18238 this.element.appendChild(this.elementContents);
18241 this.element.insertBefore(this.arrowElement, this.element.firstChild);
18246 Group.prototype.getElement = function () {
18247 this.addBindingsd = false;
18251 if (this.visible) {
18252 this.element.classList.add("tabulator-group-visible
");
18254 this.element.classList.remove("tabulator-group-visible
");
18257 for (var i = 0; i < this.element.childNodes.length; ++i) {
18258 this.element.childNodes[i].parentNode.removeChild(this.element.childNodes[i]);
18261 this.generateGroupHeaderContents();
18263 // this.addBindings();
18265 return this.element;
18268 Group.prototype.detachElement = function () {
18269 if (this.element && this.element.parentNode) {
18270 this.element.parentNode.removeChild(this.element);
18274 //normalize the height of elements in the row
18275 Group.prototype.normalizeHeight = function () {
18276 this.setHeight(this.element.clientHeight);
18279 Group.prototype.initialize = function (force) {
18280 if (!this.initialized || force) {
18281 this.normalizeHeight();
18282 this.initialized = true;
18286 Group.prototype.reinitialize = function () {
18287 this.initialized = false;
18290 if (Tabulator.prototype.helpers.elVisible(this.element)) {
18291 this.initialize(true);
18295 Group.prototype.setHeight = function (height) {
18296 if (this.height != height) {
18297 this.height = height;
18298 this.outerHeight = this.element.offsetHeight;
18302 //return rows outer height
18303 Group.prototype.getHeight = function () {
18304 return this.outerHeight;
18307 Group.prototype.getGroup = function () {
18311 Group.prototype.reinitializeHeight = function () {};
18312 Group.prototype.calcHeight = function () {};
18313 Group.prototype.setCellHeight = function () {};
18314 Group.prototype.clearCellHeight = function () {};
18317 Group.prototype.getComponent = function () {
18318 return new GroupComponent(this);
18325 var GroupRows = function GroupRows(table) {
18327 this.table = table; //hold Tabulator object
18329 this.groupIDLookups = false; //enable table grouping and set field to group by
18330 this.startOpen = [function () {
18332 }]; //starting state of group
18333 this.headerGenerator = [function () {
18336 this.groupList = []; //ordered list of groups
18337 this.allowedValues = false;
18338 this.groups = {}; //hold row groups
18339 this.displayIndex = 0; //index in display pipeline
18342 //initialize group configuration
18343 GroupRows.prototype.initialize = function () {
18345 groupBy = self.table.options.groupBy,
18346 startOpen = self.table.options.groupStartOpen,
18347 groupHeader = self.table.options.groupHeader;
18349 this.allowedValues = self.table.options.groupValues;
18351 if (Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length) {
18352 console.warn("Error creating group headers, groupHeader array is shorter than groupBy array
");
18355 self.headerGenerator = [function () {
18358 this.startOpen = [function () {
18360 }]; //starting state of group
18362 self.table.modules.localize.bind("groups|item
", function (langValue, lang) {
18363 self.headerGenerator[0] = function (value, count, data) {
18364 //header layout function
18365 return (typeof value === "undefined
" ? "" : value) + "<span>(
" + count + " " + (count === 1 ? langValue : lang.groups.items) + ")</span>
";
18369 this.groupIDLookups = [];
18371 if (Array.isArray(groupBy) || groupBy) {
18372 if (this.table.modExists("columnCalcs
") && this.table.options.columnCalcs != "table
" && this.table.options.columnCalcs != "both
") {
18373 this.table.modules.columnCalcs.removeCalcs();
18376 if (this.table.modExists("columnCalcs
") && this.table.options.columnCalcs != "group
") {
18378 var cols = this.table.columnManager.getRealColumns();
18380 cols.forEach(function (col) {
18381 if (col.definition.topCalc) {
18382 self.table.modules.columnCalcs.initializeTopRow();
18385 if (col.definition.bottomCalc) {
18386 self.table.modules.columnCalcs.initializeBottomRow();
18392 if (!Array.isArray(groupBy)) {
18393 groupBy = [groupBy];
18396 groupBy.forEach(function (group, i) {
18397 var lookupFunc, column;
18399 if (typeof group == "function") {
18400 lookupFunc = group;
18402 column = self.table.columnManager.getColumnByField(group);
18405 lookupFunc = function lookupFunc(data) {
18406 return column.getFieldValue(data);
18409 lookupFunc = function lookupFunc(data) {
18410 return data[group];
18415 self.groupIDLookups.push({
18416 field: typeof group === "function" ? false : group,
18418 values: self.allowedValues ? self.allowedValues[i] : false
18424 if (!Array.isArray(startOpen)) {
18425 startOpen = [startOpen];
18428 startOpen.forEach(function (level) {
18429 level = typeof level == "function" ? level : function () {
18434 self.startOpen = startOpen;
18438 self.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader];
18441 this.initialized = true;
18444 GroupRows.prototype.setDisplayIndex = function (index) {
18445 this.displayIndex = index;
18448 GroupRows.prototype.getDisplayIndex = function () {
18449 return this.displayIndex;
18452 //return appropriate rows with group headers
18453 GroupRows.prototype.getRows = function (rows) {
18454 if (this.groupIDLookups.length) {
18456 this.table.options.dataGrouping.call(this.table);
18458 this.generateGroups(rows);
18460 if (this.table.options.dataGrouped) {
18461 this.table.options.dataGrouped.call(this.table, this.getGroups(true));
18464 return this.updateGroupRows();
18466 return rows.slice(0);
18470 GroupRows.prototype.getGroups = function (compoment) {
18471 var groupComponents = [];
18473 this.groupList.forEach(function (group) {
18474 groupComponents.push(compoment ? group.getComponent() : group);
18477 return groupComponents;
18480 GroupRows.prototype.wipe = function () {
18481 this.groupList.forEach(function (group) {
18486 GroupRows.prototype.pullGroupListData = function (groupList) {
18488 var groupListData = [];
18490 groupList.forEach(function (group) {
18491 var groupHeader = {};
18492 groupHeader.level = 0;
18493 groupHeader.rowCount = 0;
18494 groupHeader.headerContent = "";
18495 var childData = [];
18497 if (group.hasSubGroups) {
18498 childData = self.pullGroupListData(group.groupList);
18500 groupHeader.level = group.level;
18501 groupHeader.rowCount = childData.length - group.groupList.length; // data length minus number of sub-headers
18502 groupHeader.headerContent = group.generator(group.key, groupHeader.rowCount, group.rows, group);
18504 groupListData.push(groupHeader);
18505 groupListData = groupListData.concat(childData);
18507 groupHeader.level = group.level;
18508 groupHeader.headerContent = group.generator(group.key, group.rows.length, group.rows, group);
18509 groupHeader.rowCount = group.getRows().length;
18511 groupListData.push(groupHeader);
18513 group.getRows().forEach(function (row) {
18514 groupListData.push(row.getData("data
"));
18519 return groupListData;
18522 GroupRows.prototype.getGroupedData = function () {
18524 return this.pullGroupListData(this.groupList);
18527 GroupRows.prototype.getRowGroup = function (row) {
18530 this.groupList.forEach(function (group) {
18531 var result = group.getRowGroup(row);
18541 GroupRows.prototype.countGroups = function () {
18542 return this.groupList.length;
18545 GroupRows.prototype.generateGroups = function (rows) {
18547 oldGroups = self.groups;
18550 self.groupList = [];
18552 if (this.allowedValues && this.allowedValues[0]) {
18553 this.allowedValues[0].forEach(function (value) {
18554 self.createGroup(value, 0, oldGroups);
18557 rows.forEach(function (row) {
18558 self.assignRowToExistingGroup(row, oldGroups);
18561 rows.forEach(function (row) {
18562 self.assignRowToGroup(row, oldGroups);
18567 GroupRows.prototype.createGroup = function (groupID, level, oldGroups) {
18568 var groupKey = level + "_
" + groupID,
18571 oldGroups = oldGroups || [];
18573 group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]);
18575 this.groups[groupKey] = group;
18576 this.groupList.push(group);
18579 // GroupRows.prototype.assignRowToGroup = function(row, oldGroups){
18580 // var groupID = this.groupIDLookups[0].func(row.getData()),
18581 // groupKey = "0_
" + groupID;
18583 // if(!this.groups[groupKey]){
18584 // this.createGroup(groupID, 0, oldGroups);
18587 // this.groups[groupKey].addRow(row);
18590 GroupRows.prototype.assignRowToExistingGroup = function (row, oldGroups) {
18591 var groupID = this.groupIDLookups[0].func(row.getData()),
18592 groupKey = "0_
" + groupID;
18594 if (this.groups[groupKey]) {
18595 this.groups[groupKey].addRow(row);
18599 GroupRows.prototype.assignRowToGroup = function (row, oldGroups) {
18600 var groupID = this.groupIDLookups[0].func(row.getData()),
18601 newGroupNeeded = !this.groups["0_
" + groupID];
18603 if (newGroupNeeded) {
18604 this.createGroup(groupID, 0, oldGroups);
18607 this.groups["0_
" + groupID].addRow(row);
18609 return !newGroupNeeded;
18612 GroupRows.prototype.updateGroupRows = function (force) {
18617 self.groupList.forEach(function (group) {
18618 output = output.concat(group.getHeadersAndRows());
18621 //force update of table display
18624 var displayIndex = self.table.rowManager.setDisplayRows(output, this.getDisplayIndex());
18626 if (displayIndex !== true) {
18627 this.setDisplayIndex(displayIndex);
18630 self.table.rowManager.refreshActiveData("group
", true, true);
18636 GroupRows.prototype.scrollHeaders = function (left) {
18637 left = left + "px
";
18639 this.groupList.forEach(function (group) {
18640 group.scrollHeader(left);
18644 GroupRows.prototype.removeGroup = function (group) {
18645 var groupKey = group.level + "_
" + group.key,
18648 if (this.groups[groupKey]) {
18649 delete this.groups[groupKey];
18651 index = this.groupList.indexOf(group);
18654 this.groupList.splice(index, 1);
18659 Tabulator.prototype.registerModule("groupRows
", GroupRows);
18660 var History = function History(table) {
18661 this.table = table; //hold Tabulator object
18667 History.prototype.clear = function () {
18672 History.prototype.action = function (type, component, data) {
18674 this.history = this.history.slice(0, this.index + 1);
18676 this.history.push({
18678 component: component,
18685 History.prototype.getHistoryUndoSize = function () {
18686 return this.index + 1;
18689 History.prototype.getHistoryRedoSize = function () {
18690 return this.history.length - (this.index + 1);
18693 History.prototype.undo = function () {
18695 if (this.index > -1) {
18696 var action = this.history[this.index];
18698 this.undoers[action.type].call(this, action);
18702 this.table.options.historyUndo.call(this.table, action.type, action.component.getComponent(), action.data);
18706 console.warn("History Undo Error - No more history to undo
");
18711 History.prototype.redo = function () {
18712 if (this.history.length - 1 > this.index) {
18716 var action = this.history[this.index];
18718 this.redoers[action.type].call(this, action);
18720 this.table.options.historyRedo.call(this.table, action.type, action.component.getComponent(), action.data);
18724 console.warn("History Redo Error - No more history to redo
");
18729 History.prototype.undoers = {
18730 cellEdit: function cellEdit(action) {
18731 action.component.setValueProcessData(action.data.oldValue);
18734 rowAdd: function rowAdd(action) {
18735 action.component.deleteActual();
18738 rowDelete: function rowDelete(action) {
18739 var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);
18741 if (this.table.options.groupBy && this.table.modExists("groupRows
")) {
18742 this.table.modules.groupRows.updateGroupRows(true);
18745 this._rebindRow(action.component, newRow);
18748 rowMove: function rowMove(action) {
18749 this.table.rowManager.moveRowActual(action.component, this.table.rowManager.rows[action.data.pos], false);
18750 this.table.rowManager.redraw();
18754 History.prototype.redoers = {
18755 cellEdit: function cellEdit(action) {
18756 action.component.setValueProcessData(action.data.newValue);
18759 rowAdd: function rowAdd(action) {
18760 var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);
18762 if (this.table.options.groupBy && this.table.modExists("groupRows
")) {
18763 this.table.modules.groupRows.updateGroupRows(true);
18766 this._rebindRow(action.component, newRow);
18769 rowDelete: function rowDelete(action) {
18770 action.component.deleteActual();
18773 rowMove: function rowMove(action) {
18774 this.table.rowManager.moveRowActual(action.component, this.table.rowManager.rows[action.data.pos], false);
18775 this.table.rowManager.redraw();
18779 //rebind rows to new element after deletion
18780 History.prototype._rebindRow = function (oldRow, newRow) {
18781 this.history.forEach(function (action) {
18782 if (action.component instanceof Row) {
18783 if (action.component === oldRow) {
18784 action.component = newRow;
18786 } else if (action.component instanceof Cell) {
18787 if (action.component.row === oldRow) {
18788 var field = action.component.column.getField();
18791 action.component = newRow.getCell(field);
18798 Tabulator.prototype.registerModule("history
", History);
18799 var HtmlTableImport = function HtmlTableImport(table) {
18800 this.table = table; //hold Tabulator object
18801 this.fieldIndex = [];
18802 this.hasIndex = false;
18805 HtmlTableImport.prototype.parseTable = function () {
18807 element = self.table.element,
18808 options = self.table.options,
18809 columns = options.columns,
18810 headers = element.getElementsByTagName("th
"),
18811 rows = element.getElementsByTagName("tbody
")[0],
18815 self.hasIndex = false;
18817 self.table.options.htmlImporting.call(this.table);
18819 rows = rows ? rows.getElementsByTagName("tr
") : [];
18821 //check for tablator inline options
18822 self._extractOptions(element, options);
18824 if (headers.length) {
18825 self._extractHeaders(headers, rows);
18827 self._generateBlankHeaders(headers, rows);
18830 //iterate through table rows and build data set
18831 for (var index = 0; index < rows.length; index++) {
18832 var row = rows[index],
18833 cells = row.getElementsByTagName("td
"),
18836 //create index if the dont exist in table
18837 if (!self.hasIndex) {
18838 item[options.index] = index;
18841 for (var i = 0; i < cells.length; i++) {
18842 var cell = cells[i];
18843 if (typeof this.fieldIndex[i] !== "undefined
") {
18844 item[this.fieldIndex[i]] = cell.innerHTML;
18848 //add row data to item
18852 //create new element
18853 var newElement = document.createElement("div
");
18855 //transfer attributes to new element
18856 var attributes = element.attributes;
18858 // loop through attributes and apply them on div
18860 for (var i in attributes) {
18861 if (_typeof(attributes[i]) == "object") {
18862 newElement.setAttribute(attributes[i].name, attributes[i].value);
18866 // replace table with div element
18867 element.parentNode.replaceChild(newElement, element);
18869 options.data = data;
18871 self.table.options.htmlImported.call(this.table);
18873 // // newElement.tabulator(options);
18875 this.table.element = newElement;
18878 //extract tabulator attribute options
18879 HtmlTableImport.prototype._extractOptions = function (element, options, defaultOptions) {
18880 var attributes = element.attributes;
18881 var optionsArr = defaultOptions ? Object.assign([], defaultOptions) : Object.keys(options);
18882 var optionsList = {};
18884 optionsArr.forEach(function (item) {
18885 optionsList[item.toLowerCase()] = item;
18888 for (var index in attributes) {
18889 var attrib = attributes[index];
18892 if (attrib && (typeof attrib === 'undefined' ? 'undefined' : _typeof(attrib)) == "object" && attrib.name && attrib.name.indexOf("tabulator-
") === 0) {
18893 name = attrib.name.replace("tabulator-
", "");
18895 if (typeof optionsList[name] !== "undefined
") {
18896 options[optionsList[name]] = this._attribValue(attrib.value);
18902 //get value of attribute
18903 HtmlTableImport.prototype._attribValue = function (value) {
18904 if (value === "true") {
18908 if (value === "false") {
18915 //find column if it has already been defined
18916 HtmlTableImport.prototype._findCol = function (title) {
18917 var match = this.table.options.columns.find(function (column) {
18918 return column.title === title;
18921 return match || false;
18924 //extract column from headers
18925 HtmlTableImport.prototype._extractHeaders = function (headers, rows) {
18926 for (var index = 0; index < headers.length; index++) {
18927 var header = headers[index],
18929 col = this._findCol(header.textContent),
18936 col = { title: header.textContent.trim() };
18940 col.field = header.textContent.trim().toLowerCase().replace(" ", "_
");
18943 width = header.getAttribute("width
");
18945 if (width && !col.width) {
18949 //check for tablator inline options
18950 attributes = header.attributes;
18952 // //check for tablator inline options
18953 this._extractOptions(header, col, Column.prototype.defaultOptionList);
18955 for (var i in attributes) {
18956 var attrib = attributes[i],
18959 if (attrib && (typeof attrib === 'undefined' ? 'undefined' : _typeof(attrib)) == "object" && attrib.name && attrib.name.indexOf("tabulator-
") === 0) {
18961 name = attrib.name.replace("tabulator-
", "");
18963 col[name] = this._attribValue(attrib.value);
18967 this.fieldIndex[index] = col.field;
18969 if (col.field == this.table.options.index) {
18970 this.hasIndex = true;
18974 this.table.options.columns.push(col);
18979 //generate blank headers
18980 HtmlTableImport.prototype._generateBlankHeaders = function (headers, rows) {
18981 for (var index = 0; index < headers.length; index++) {
18982 var header = headers[index],
18983 col = { title: "", field: "col
" + index };
18985 this.fieldIndex[index] = col.field;
18987 var width = header.getAttribute("width
");
18993 this.table.options.columns.push(col);
18997 Tabulator.prototype.registerModule("htmlTableImport
", HtmlTableImport);
18998 var HtmlTableExport = function HtmlTableExport(table) {
18999 this.table = table; //hold Tabulator object
19001 this.cloneTableStyle = true;
19002 this.colVisProp = "";
19005 HtmlTableExport.prototype.genereateTable = function (config, style, visible, colVisProp) {
19006 this.cloneTableStyle = style;
19007 this.config = config || {};
19008 this.colVisProp = colVisProp;
19010 var headers = this.generateHeaderElements();
19011 var body = this.generateBodyElements(visible);
19013 var table = document.createElement("table
");
19014 table.classList.add("tabulator-print-table
");
19015 table.appendChild(headers);
19016 table.appendChild(body);
19018 this.mapElementStyles(this.table.element, table, ["border-top
", "border-left
", "border-right
", "border-bottom
"]);
19023 HtmlTableExport.prototype.generateColumnGroupHeaders = function () {
19024 var _this53 = this;
19028 var columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex;
19030 columns.forEach(function (column) {
19031 var colData = _this53.processColumnGroup(column);
19034 output.push(colData);
19041 HtmlTableExport.prototype.processColumnGroup = function (column) {
19042 var _this54 = this;
19044 var subGroups = column.columns,
19048 title: column.definition.title,
19053 if (subGroups.length) {
19054 groupData.subGroups = [];
19055 groupData.width = 0;
19057 subGroups.forEach(function (subGroup) {
19058 var subGroupData = _this54.processColumnGroup(subGroup);
19060 if (subGroupData) {
19061 groupData.width += subGroupData.width;
19062 groupData.subGroups.push(subGroupData);
19064 if (subGroupData.depth > maxDepth) {
19065 maxDepth = subGroupData.depth;
19070 groupData.depth += maxDepth;
19072 if (!groupData.width) {
19076 if (this.columnVisCheck(column)) {
19077 groupData.width = 1;
19086 HtmlTableExport.prototype.groupHeadersToRows = function (columns) {
19091 function parseColumnGroup(column, level) {
19093 var depth = headerDepth - level;
19095 if (typeof headers[level] === "undefined
") {
19096 headers[level] = [];
19099 column.height = column.subGroups ? 1 : depth - column.depth + 1;
19101 headers[level].push(column);
19103 if (column.subGroups) {
19104 column.subGroups.forEach(function (subGroup) {
19105 parseColumnGroup(subGroup, level + 1);
19110 //calculate maximum header debth
19111 columns.forEach(function (column) {
19112 if (column.depth > headerDepth) {
19113 headerDepth = column.depth;
19117 columns.forEach(function (column) {
19118 parseColumnGroup(column, 0);
19124 HtmlTableExport.prototype.generateHeaderElements = function () {
19125 var _this55 = this;
19127 var headerEl = document.createElement("thead
");
19129 var rows = this.groupHeadersToRows(this.generateColumnGroupHeaders());
19131 rows.forEach(function (row) {
19132 var rowEl = document.createElement("tr
");
19134 _this55.mapElementStyles(_this55.table.columnManager.getHeadersElement(), headerEl, ["border-top
", "border-left
", "border-right
", "border-bottom
", "background-color
", "color
", "font-weight
", "font-family
", "font-size
"]);
19136 row.forEach(function (column) {
19137 var cellEl = document.createElement("th
");
19138 var classNames = column.column.definition.cssClass ? column.column.definition.cssClass.split(" ") : [];
19140 cellEl.colSpan = column.width;
19141 cellEl.rowSpan = column.height;
19143 cellEl.innerHTML = column.column.definition.title;
19145 if (_this55.cloneTableStyle) {
19146 cellEl.style.boxSizing = "border-box
";
19149 classNames.forEach(function (className) {
19150 cellEl.classList.add(className);
19153 _this55.mapElementStyles(column.column.getElement(), cellEl, ["text-align
", "border-top
", "border-left
", "border-right
", "border-bottom
", "background-color
", "color
", "font-weight
", "font-family
", "font-size
"]);
19154 _this55.mapElementStyles(column.column.contentElement, cellEl, ["padding-top
", "padding-left
", "padding-right
", "padding-bottom
"]);
19156 if (column.column.visible) {
19157 _this55.mapElementStyles(column.column.getElement(), cellEl, ["width
"]);
19159 if (column.column.definition.width) {
19160 cellEl.style.width = column.column.definition.width + "px
";
19164 if (column.column.parent) {
19165 _this55.mapElementStyles(column.column.parent.groupElement, cellEl, ["border-top
"]);
19168 rowEl.appendChild(cellEl);
19171 headerEl.appendChild(rowEl);
19177 HtmlTableExport.prototype.generateBodyElements = function (visible) {
19178 var _this56 = this;
19180 var oddRow, evenRow, calcRow, firstRow, firstCell, firstGroup, lastCell, styleCells, styleRow;
19182 //lookup row styles
19183 if (this.cloneTableStyle && window.getComputedStyle) {
19184 oddRow = this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)
");
19185 evenRow = this.table.element.querySelector(".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)
");
19186 calcRow = this.table.element.querySelector(".tabulator-row.tabulator-calcs
");
19187 firstRow = this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)
");
19188 firstGroup = this.table.element.getElementsByClassName("tabulator-group
")[0];
19191 styleCells = firstRow.getElementsByClassName("tabulator-cell
");
19192 firstCell = styleCells[0];
19193 lastCell = styleCells[styleCells.length - 1];
19197 var bodyEl = document.createElement("tbody
");
19199 var rows = visible ? this.table.rowManager.getVisibleRows(true) : this.table.rowManager.getDisplayRows();
19202 if (this.config.columnCalcs !== false && this.table.modExists("columnCalcs
")) {
19203 if (this.table.modules.columnCalcs.topInitialized) {
19204 rows.unshift(this.table.modules.columnCalcs.topRow);
19207 if (this.table.modules.columnCalcs.botInitialized) {
19208 rows.push(this.table.modules.columnCalcs.botRow);
19212 this.table.columnManager.columnsByIndex.forEach(function (column) {
19213 if (_this56.columnVisCheck(column)) {
19214 columns.push(column);
19218 rows = rows.filter(function (row) {
19219 switch (row.type) {
19221 return _this56.config.rowGroups !== false;
19225 return _this56.config.columnCalcs !== false;
19232 if (rows.length > 1000) {
19233 console.warn("It may take a long time to render an HTML table with more than 1000 rows
");
19236 rows.forEach(function (row, i) {
19237 var rowData = row.getData();
19239 var rowEl = document.createElement("tr
");
19240 rowEl.classList.add("tabulator-print-table-row
");
19242 switch (row.type) {
19244 var cellEl = document.createElement("td
");
19245 cellEl.colSpan = columns.length;
19246 cellEl.innerHTML = row.key;
19248 rowEl.classList.add("tabulator-print-table-group
");
19250 _this56.mapElementStyles(firstGroup, rowEl, ["border-top
", "border-left
", "border-right
", "border-bottom
", "color
", "font-weight
", "font-family
", "font-size
", "background-color
"]);
19251 _this56.mapElementStyles(firstGroup, cellEl, ["padding-top
", "padding-left
", "padding-right
", "padding-bottom
"]);
19252 rowEl.appendChild(cellEl);
19256 rowEl.classList.add("tabulator-print-table-calcs
");
19259 columns.forEach(function (column) {
19260 var cellEl = document.createElement("td
");
19262 var value = column.getFieldValue(rowData);
19264 var cellWrapper = {
19266 getValue: function getValue() {
19269 getField: function getField() {
19270 return column.definition.field;
19272 getElement: function getElement() {
19275 getColumn: function getColumn() {
19276 return column.getComponent();
19278 getData: function getData() {
19281 getRow: function getRow() {
19282 return row.getComponent();
19284 getComponent: function getComponent() {
19285 return cellWrapper;
19290 var classNames = column.definition.cssClass ? column.definition.cssClass.split(" ") : [];
19292 classNames.forEach(function (className) {
19293 cellEl.classList.add(className);
19296 if (_this56.table.modExists("format
")) {
19297 value = _this56.table.modules.format.formatValue(cellWrapper);
19299 switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
19301 value = JSON.stringify(value);
19314 if (value instanceof Node) {
19315 cellEl.appendChild(value);
19317 cellEl.innerHTML = value;
19321 _this56.mapElementStyles(firstCell, cellEl, ["padding-top
", "padding-left
", "padding-right
", "padding-bottom
", "border-top
", "border-left
", "border-right
", "border-bottom
", "color
", "font-weight
", "font-family
", "font-size
", "text-align
"]);
19324 rowEl.appendChild(cellEl);
19327 styleRow = row.type == "calc
" ? calcRow : i % 2 && evenRow ? evenRow : oddRow;
19329 _this56.mapElementStyles(styleRow, rowEl, ["border-top
", "border-left
", "border-right
", "border-bottom
", "color
", "font-weight
", "font-family
", "font-size
", "background-color
"]);
19333 bodyEl.appendChild(rowEl);
19339 HtmlTableExport.prototype.columnVisCheck = function (column) {
19340 return column.definition[this.colVisProp] !== false && (column.visible || !column.visible && column.definition[this.colVisProp]);
19343 HtmlTableExport.prototype.getHtml = function (visible, style, config) {
19344 var holder = document.createElement("div
");
19346 holder.appendChild(this.genereateTable(config || this.table.options.htmlOutputConfig, style, visible, "htmlOutput
"));
19348 return holder.innerHTML;
19351 HtmlTableExport.prototype.mapElementStyles = function (from, to, props) {
19352 if (this.cloneTableStyle && from && to) {
19355 "background-color
": "backgroundColor
",
19356 "color
": "fontColor
",
19358 "font-weight
": "fontWeight
",
19359 "font-family
": "fontFamily
",
19360 "font-size
": "fontSize
",
19361 "text-align
": "textAlign
",
19362 "border-top
": "borderTop
",
19363 "border-left
": "borderLeft
",
19364 "border-right
": "borderRight
",
19365 "border-bottom
": "borderBottom
",
19366 "padding-top
": "paddingTop
",
19367 "padding-left
": "paddingLeft
",
19368 "padding-right
": "paddingRight
",
19369 "padding-bottom
": "paddingBottom
"
19372 if (window.getComputedStyle) {
19373 var fromStyle = window.getComputedStyle(from);
19375 props.forEach(function (prop) {
19376 to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);
19382 Tabulator.prototype.registerModule("htmlTableExport
", HtmlTableExport);
19384 var Keybindings = function Keybindings(table) {
19385 this.table = table; //hold Tabulator object
19386 this.watchKeys = null;
19387 this.pressedKeys = null;
19388 this.keyupBinding = false;
19389 this.keydownBinding = false;
19392 Keybindings.prototype.initialize = function () {
19393 var bindings = this.table.options.keybindings,
19394 mergedBindings = {};
19396 this.watchKeys = {};
19397 this.pressedKeys = [];
19399 if (bindings !== false) {
19401 for (var key in this.bindings) {
19402 mergedBindings[key] = this.bindings[key];
19405 if (Object.keys(bindings).length) {
19407 for (var _key in bindings) {
19408 mergedBindings[_key] = bindings[_key];
19412 this.mapBindings(mergedBindings);
19417 Keybindings.prototype.mapBindings = function (bindings) {
19418 var _this57 = this;
19422 var _loop2 = function _loop2(key) {
19424 if (_this57.actions[key]) {
19426 if (bindings[key]) {
19428 if (_typeof(bindings[key]) !== "object
") {
19429 bindings[key] = [bindings[key]];
19432 bindings[key].forEach(function (binding) {
19433 self.mapBinding(key, binding);
19437 console.warn("Key Binding Error - no such action:
", key);
19441 for (var key in bindings) {
19446 Keybindings.prototype.mapBinding = function (action, symbolsList) {
19450 action: this.actions[action],
19456 var symbols = symbolsList.toString().toLowerCase().split(" ").join("").split("+
");
19458 symbols.forEach(function (symbol) {
19461 binding.ctrl = true;
19465 binding.shift = true;
19469 symbol = parseInt(symbol);
19470 binding.keys.push(symbol);
19472 if (!self.watchKeys[symbol]) {
19473 self.watchKeys[symbol] = [];
19476 self.watchKeys[symbol].push(binding);
19481 Keybindings.prototype.bindEvents = function () {
19484 this.keyupBinding = function (e) {
19485 var code = e.keyCode;
19486 var bindings = self.watchKeys[code];
19490 self.pressedKeys.push(code);
19492 bindings.forEach(function (binding) {
19493 self.checkBinding(e, binding);
19498 this.keydownBinding = function (e) {
19499 var code = e.keyCode;
19500 var bindings = self.watchKeys[code];
19504 var index = self.pressedKeys.indexOf(code);
19507 self.pressedKeys.splice(index, 1);
19512 this.table.element.addEventListener("keydown
", this.keyupBinding);
19514 this.table.element.addEventListener("keyup
", this.keydownBinding);
19517 Keybindings.prototype.clearBindings = function () {
19518 if (this.keyupBinding) {
19519 this.table.element.removeEventListener("keydown
", this.keyupBinding);
19522 if (this.keydownBinding) {
19523 this.table.element.removeEventListener("keyup
", this.keydownBinding);
19527 Keybindings.prototype.checkBinding = function (e, binding) {
19531 if (e.ctrlKey == binding.ctrl && e.shiftKey == binding.shift) {
19532 binding.keys.forEach(function (key) {
19533 var index = self.pressedKeys.indexOf(key);
19541 binding.action.call(self, e);
19551 Keybindings.prototype.bindings = {
19552 navPrev: "shift + 9
",
19557 scrollPageDown: 34,
19562 copyToClipboard: "ctrl + 67
"
19566 Keybindings.prototype.actions = {
19567 keyBlock: function keyBlock(e) {
19568 e.stopPropagation();
19569 e.preventDefault();
19571 scrollPageUp: function scrollPageUp(e) {
19572 var rowManager = this.table.rowManager,
19573 newPos = rowManager.scrollTop - rowManager.height,
19574 scrollMax = rowManager.element.scrollHeight;
19576 e.preventDefault();
19578 if (rowManager.displayRowsCount) {
19580 rowManager.element.scrollTop = newPos;
19582 rowManager.scrollToRow(rowManager.getDisplayRows()[0]);
19586 this.table.element.focus();
19588 scrollPageDown: function scrollPageDown(e) {
19589 var rowManager = this.table.rowManager,
19590 newPos = rowManager.scrollTop + rowManager.height,
19591 scrollMax = rowManager.element.scrollHeight;
19593 e.preventDefault();
19595 if (rowManager.displayRowsCount) {
19596 if (newPos <= scrollMax) {
19597 rowManager.element.scrollTop = newPos;
19599 rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);
19603 this.table.element.focus();
19605 scrollToStart: function scrollToStart(e) {
19606 var rowManager = this.table.rowManager;
19608 e.preventDefault();
19610 if (rowManager.displayRowsCount) {
19611 rowManager.scrollToRow(rowManager.getDisplayRows()[0]);
19614 this.table.element.focus();
19616 scrollToEnd: function scrollToEnd(e) {
19617 var rowManager = this.table.rowManager;
19619 e.preventDefault();
19621 if (rowManager.displayRowsCount) {
19622 rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);
19625 this.table.element.focus();
19627 navPrev: function navPrev(e) {
19630 if (this.table.modExists("edit
")) {
19631 cell = this.table.modules.edit.currentCell;
19634 e.preventDefault();
19640 navNext: function navNext(e) {
19642 var newRow = this.table.options.tabEndNewRow;
19645 if (this.table.modExists("edit
")) {
19646 cell = this.table.modules.edit.currentCell;
19649 e.preventDefault();
19655 if (newRow === true) {
19656 newRow = this.table.addRow({});
19658 if (typeof newRow == "function
") {
19659 newRow = this.table.addRow(newRow(cell.row.getComponent()));
19661 newRow = this.table.addRow(newRow);
19665 newRow.then(function () {
19674 navLeft: function navLeft(e) {
19677 if (this.table.modExists("edit
")) {
19678 cell = this.table.modules.edit.currentCell;
19681 e.preventDefault();
19687 navRight: function navRight(e) {
19690 if (this.table.modExists("edit
")) {
19691 cell = this.table.modules.edit.currentCell;
19694 e.preventDefault();
19695 cell.nav().right();
19700 navUp: function navUp(e) {
19703 if (this.table.modExists("edit
")) {
19704 cell = this.table.modules.edit.currentCell;
19707 e.preventDefault();
19713 navDown: function navDown(e) {
19716 if (this.table.modExists("edit
")) {
19717 cell = this.table.modules.edit.currentCell;
19720 e.preventDefault();
19726 undo: function undo(e) {
19728 if (this.table.options.history && this.table.modExists("history
") && this.table.modExists("edit
")) {
19730 cell = this.table.modules.edit.currentCell;
19733 e.preventDefault();
19734 this.table.modules.history.undo();
19739 redo: function redo(e) {
19741 if (this.table.options.history && this.table.modExists("history
") && this.table.modExists("edit
")) {
19743 cell = this.table.modules.edit.currentCell;
19746 e.preventDefault();
19747 this.table.modules.history.redo();
19752 copyToClipboard: function copyToClipboard(e) {
19753 if (!this.table.modules.edit.currentCell) {
19754 if (this.table.modExists("clipboard
", true)) {
19755 this.table.modules.clipboard.copy(!this.table.options.selectable || this.table.options.selectable == "highlight
" ? "active
" : "selected
", null, null, null, true);
19761 Tabulator.prototype.registerModule("keybindings
", Keybindings);
19762 var MoveColumns = function MoveColumns(table) {
19763 this.table = table; //hold Tabulator object
19764 this.placeholderElement = this.createPlaceholderElement();
19765 this.hoverElement = false; //floating column header element
19766 this.checkTimeout = false; //click check timeout holder
19767 this.checkPeriod = 250; //period to wait on mousedown to consider this a move and not a click
19768 this.moving = false; //currently moving column
19769 this.toCol = false; //destination column
19770 this.toColAfter = false; //position of moving column relative to the desitnation column
19771 this.startX = 0; //starting position within header element
19772 this.autoScrollMargin = 40; //auto scroll on edge when within margin
19773 this.autoScrollStep = 5; //auto scroll distance in pixels
19774 this.autoScrollTimeout = false; //auto scroll timeout
19775 this.touchMove = false;
19777 this.moveHover = this.moveHover.bind(this);
19778 this.endMove = this.endMove.bind(this);
19781 MoveColumns.prototype.createPlaceholderElement = function () {
19782 var el = document.createElement("div
");
19784 el.classList.add("tabulator-col
");
19785 el.classList.add("tabulator-col-placeholder
");
19790 MoveColumns.prototype.initializeColumn = function (column) {
19795 if (!column.modules.frozen) {
19797 colEl = column.getElement();
19799 config.mousemove = function (e) {
19800 if (column.parent === self.moving.parent) {
19801 if ((self.touchMove ? e.touches[0].pageX : e.pageX) - Tabulator.prototype.helpers.elOffset(colEl).left + self.table.columnManager.element.scrollLeft > column.getWidth() / 2) {
19802 if (self.toCol !== column || !self.toColAfter) {
19803 colEl.parentNode.insertBefore(self.placeholderElement, colEl.nextSibling);
19804 self.moveColumn(column, true);
19807 if (self.toCol !== column || self.toColAfter) {
19808 colEl.parentNode.insertBefore(self.placeholderElement, colEl);
19809 self.moveColumn(column, false);
19815 colEl.addEventListener("mousedown
", function (e) {
19816 self.touchMove = false;
19817 if (e.which === 1) {
19818 self.checkTimeout = setTimeout(function () {
19819 self.startMove(e, column);
19820 }, self.checkPeriod);
19824 colEl.addEventListener("mouseup
", function (e) {
19825 if (e.which === 1) {
19826 if (self.checkTimeout) {
19827 clearTimeout(self.checkTimeout);
19832 self.bindTouchEvents(column);
19835 column.modules.moveColumn = config;
19838 MoveColumns.prototype.bindTouchEvents = function (column) {
19840 colEl = column.getElement(),
19841 startXMove = false,
19842 //shifting center position of the cell
19852 colEl.addEventListener("touchstart
", function (e) {
19853 self.checkTimeout = setTimeout(function () {
19854 self.touchMove = true;
19855 currentCol = column;
19856 nextCol = column.nextColumn();
19857 nextColWidth = nextCol ? nextCol.getWidth() / 2 : 0;
19858 prevCol = column.prevColumn();
19859 prevColWidth = prevCol ? prevCol.getWidth() / 2 : 0;
19860 nextColWidthLast = 0;
19861 prevColWidthLast = 0;
19862 startXMove = false;
19864 self.startMove(e, column);
19865 }, self.checkPeriod);
19866 }, { passive: true });
19868 colEl.addEventListener("touchmove
", function (e) {
19869 var halfCol, diff, moveToCol;
19875 startXMove = e.touches[0].pageX;
19878 diff = e.touches[0].pageX - startXMove;
19881 if (nextCol && diff - nextColWidthLast > nextColWidth) {
19882 moveToCol = nextCol;
19884 if (moveToCol !== column) {
19885 startXMove = e.touches[0].pageX;
19886 moveToCol.getElement().parentNode.insertBefore(self.placeholderElement, moveToCol.getElement().nextSibling);
19887 self.moveColumn(moveToCol, true);
19891 if (prevCol && -diff - prevColWidthLast > prevColWidth) {
19892 moveToCol = prevCol;
19894 if (moveToCol !== column) {
19895 startXMove = e.touches[0].pageX;
19896 moveToCol.getElement().parentNode.insertBefore(self.placeholderElement, moveToCol.getElement());
19897 self.moveColumn(moveToCol, false);
19903 currentCol = moveToCol;
19904 nextCol = moveToCol.nextColumn();
19905 nextColWidthLast = nextColWidth;
19906 nextColWidth = nextCol ? nextCol.getWidth() / 2 : 0;
19907 prevCol = moveToCol.prevColumn();
19908 prevColWidthLast = prevColWidth;
19909 prevColWidth = prevCol ? prevCol.getWidth() / 2 : 0;
19912 }, { passive: true });
19914 colEl.addEventListener("touchend
", function (e) {
19915 if (self.checkTimeout) {
19916 clearTimeout(self.checkTimeout);
19924 MoveColumns.prototype.startMove = function (e, column) {
19925 var element = column.getElement();
19927 this.moving = column;
19928 this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Tabulator.prototype.helpers.elOffset(element).left;
19930 this.table.element.classList.add("tabulator-block-select
");
19932 //create placeholder
19933 this.placeholderElement.style.width = column.getWidth() + "px
";
19934 this.placeholderElement.style.height = column.getHeight() + "px
";
19936 element.parentNode.insertBefore(this.placeholderElement, element);
19937 element.parentNode.removeChild(element);
19939 //create hover element
19940 this.hoverElement = element.cloneNode(true);
19941 this.hoverElement.classList.add("tabulator-moving
");
19943 this.table.columnManager.getElement().appendChild(this.hoverElement);
19945 this.hoverElement.style.left = "0
";
19946 this.hoverElement.style.bottom = "0
";
19948 if (!this.touchMove) {
19949 this._bindMouseMove();
19951 document.body.addEventListener("mousemove
", this.moveHover);
19952 document.body.addEventListener("mouseup
", this.endMove);
19958 MoveColumns.prototype._bindMouseMove = function () {
19959 this.table.columnManager.columnsByIndex.forEach(function (column) {
19960 if (column.modules.moveColumn.mousemove) {
19961 column.getElement().addEventListener("mousemove
", column.modules.moveColumn.mousemove);
19966 MoveColumns.prototype._unbindMouseMove = function () {
19967 this.table.columnManager.columnsByIndex.forEach(function (column) {
19968 if (column.modules.moveColumn.mousemove) {
19969 column.getElement().removeEventListener("mousemove
", column.modules.moveColumn.mousemove);
19974 MoveColumns.prototype.moveColumn = function (column, after) {
19975 var movingCells = this.moving.getCells();
19977 this.toCol = column;
19978 this.toColAfter = after;
19981 column.getCells().forEach(function (cell, i) {
19982 var cellEl = cell.getElement();
19983 cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl.nextSibling);
19986 column.getCells().forEach(function (cell, i) {
19987 var cellEl = cell.getElement();
19988 cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl);
19993 MoveColumns.prototype.endMove = function (e) {
19994 if (e.which === 1 || this.touchMove) {
19995 this._unbindMouseMove();
19997 this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);
19998 this.placeholderElement.parentNode.removeChild(this.placeholderElement);
19999 this.hoverElement.parentNode.removeChild(this.hoverElement);
20001 this.table.element.classList.remove("tabulator-block-select
");
20004 this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
20007 this.moving = false;
20008 this.toCol = false;
20009 this.toColAfter = false;
20011 if (!this.touchMove) {
20012 document.body.removeEventListener("mousemove
", this.moveHover);
20013 document.body.removeEventListener("mouseup
", this.endMove);
20018 MoveColumns.prototype.moveHover = function (e) {
20020 columnHolder = self.table.columnManager.getElement(),
20021 scrollLeft = columnHolder.scrollLeft,
20022 xPos = (self.touchMove ? e.touches[0].pageX : e.pageX) - Tabulator.prototype.helpers.elOffset(columnHolder).left + scrollLeft,
20025 self.hoverElement.style.left = xPos - self.startX + "px
";
20027 if (xPos - scrollLeft < self.autoScrollMargin) {
20028 if (!self.autoScrollTimeout) {
20029 self.autoScrollTimeout = setTimeout(function () {
20030 scrollPos = Math.max(0, scrollLeft - 5);
20031 self.table.rowManager.getElement().scrollLeft = scrollPos;
20032 self.autoScrollTimeout = false;
20037 if (scrollLeft + columnHolder.clientWidth - xPos < self.autoScrollMargin) {
20038 if (!self.autoScrollTimeout) {
20039 self.autoScrollTimeout = setTimeout(function () {
20040 scrollPos = Math.min(columnHolder.clientWidth, scrollLeft + 5);
20041 self.table.rowManager.getElement().scrollLeft = scrollPos;
20042 self.autoScrollTimeout = false;
20048 Tabulator.prototype.registerModule("moveColumn
", MoveColumns);
20050 var MoveRows = function MoveRows(table) {
20052 this.table = table; //hold Tabulator object
20053 this.placeholderElement = this.createPlaceholderElement();
20054 this.hoverElement = false; //floating row header element
20055 this.checkTimeout = false; //click check timeout holder
20056 this.checkPeriod = 150; //period to wait on mousedown to consider this a move and not a click
20057 this.moving = false; //currently moving row
20058 this.toRow = false; //destination row
20059 this.toRowAfter = false; //position of moving row relative to the desitnation row
20060 this.hasHandle = false; //row has handle instead of fully movable row
20061 this.startY = 0; //starting Y position within header element
20062 this.startX = 0; //starting X position within header element
20064 this.moveHover = this.moveHover.bind(this);
20065 this.endMove = this.endMove.bind(this);
20066 this.tableRowDropEvent = false;
20068 this.touchMove = false;
20070 this.connection = false;
20071 this.connections = [];
20073 this.connectedTable = false;
20074 this.connectedRow = false;
20077 MoveRows.prototype.createPlaceholderElement = function () {
20078 var el = document.createElement("div
");
20080 el.classList.add("tabulator-row
");
20081 el.classList.add("tabulator-row-placeholder
");
20086 MoveRows.prototype.initialize = function (handle) {
20087 this.connection = this.table.options.movableRowsConnectedTables;
20090 MoveRows.prototype.setHandle = function (handle) {
20091 this.hasHandle = handle;
20094 MoveRows.prototype.initializeGroupHeader = function (group) {
20099 //inter table drag drop
20100 config.mouseup = function (e) {
20101 self.tableRowDrop(e, row);
20104 //same table drag drop
20105 config.mousemove = function (e) {
20106 if (e.pageY - Tabulator.prototype.helpers.elOffset(group.element).top + self.table.rowManager.element.scrollTop > group.getHeight() / 2) {
20107 if (self.toRow !== group || !self.toRowAfter) {
20108 var rowEl = group.getElement();
20109 rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);
20110 self.moveRow(group, true);
20113 if (self.toRow !== group || self.toRowAfter) {
20114 var rowEl = group.getElement();
20115 if (rowEl.previousSibling) {
20116 rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);
20117 self.moveRow(group, false);
20123 group.modules.moveRow = config;
20126 MoveRows.prototype.initializeRow = function (row) {
20131 //inter table drag drop
20132 config.mouseup = function (e) {
20133 self.tableRowDrop(e, row);
20136 //same table drag drop
20137 config.mousemove = function (e) {
20138 if (e.pageY - Tabulator.prototype.helpers.elOffset(row.element).top + self.table.rowManager.element.scrollTop > row.getHeight() / 2) {
20139 if (self.toRow !== row || !self.toRowAfter) {
20140 var rowEl = row.getElement();
20141 rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);
20142 self.moveRow(row, true);
20145 if (self.toRow !== row || self.toRowAfter) {
20146 var rowEl = row.getElement();
20147 rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);
20148 self.moveRow(row, false);
20153 if (!this.hasHandle) {
20155 rowEl = row.getElement();
20157 rowEl.addEventListener("mousedown
", function (e) {
20158 if (e.which === 1) {
20159 self.checkTimeout = setTimeout(function () {
20160 self.startMove(e, row);
20161 }, self.checkPeriod);
20165 rowEl.addEventListener("mouseup
", function (e) {
20166 if (e.which === 1) {
20167 if (self.checkTimeout) {
20168 clearTimeout(self.checkTimeout);
20173 this.bindTouchEvents(row, row.getElement());
20176 row.modules.moveRow = config;
20179 MoveRows.prototype.initializeCell = function (cell) {
20181 cellEl = cell.getElement();
20183 cellEl.addEventListener("mousedown
", function (e) {
20184 if (e.which === 1) {
20185 self.checkTimeout = setTimeout(function () {
20186 self.startMove(e, cell.row);
20187 }, self.checkPeriod);
20191 cellEl.addEventListener("mouseup
", function (e) {
20192 if (e.which === 1) {
20193 if (self.checkTimeout) {
20194 clearTimeout(self.checkTimeout);
20199 this.bindTouchEvents(cell.row, cell.getElement());
20202 MoveRows.prototype.bindTouchEvents = function (row, element) {
20204 startYMove = false,
20205 //shifting center position of the cell
20215 element.addEventListener("touchstart
", function (e) {
20216 self.checkTimeout = setTimeout(function () {
20217 self.touchMove = true;
20219 nextRow = row.nextRow();
20220 nextRowHeight = nextRow ? nextRow.getHeight() / 2 : 0;
20221 prevRow = row.prevRow();
20222 prevRowHeight = prevRow ? prevRow.getHeight() / 2 : 0;
20223 nextRowHeightLast = 0;
20224 prevRowHeightLast = 0;
20225 startYMove = false;
20227 self.startMove(e, row);
20228 }, self.checkPeriod);
20229 }, { passive: true });
20230 this.moving, this.toRow, this.toRowAfter;
20231 element.addEventListener("touchmove
", function (e) {
20233 var halfCol, diff, moveToRow;
20236 e.preventDefault();
20241 startYMove = e.touches[0].pageY;
20244 diff = e.touches[0].pageY - startYMove;
20247 if (nextRow && diff - nextRowHeightLast > nextRowHeight) {
20248 moveToRow = nextRow;
20250 if (moveToRow !== row) {
20251 startYMove = e.touches[0].pageY;
20252 moveToRow.getElement().parentNode.insertBefore(self.placeholderElement, moveToRow.getElement().nextSibling);
20253 self.moveRow(moveToRow, true);
20257 if (prevRow && -diff - prevRowHeightLast > prevRowHeight) {
20258 moveToRow = prevRow;
20260 if (moveToRow !== row) {
20261 startYMove = e.touches[0].pageY;
20262 moveToRow.getElement().parentNode.insertBefore(self.placeholderElement, moveToRow.getElement());
20263 self.moveRow(moveToRow, false);
20269 currentRow = moveToRow;
20270 nextRow = moveToRow.nextRow();
20271 nextRowHeightLast = nextRowHeight;
20272 nextRowHeight = nextRow ? nextRow.getHeight() / 2 : 0;
20273 prevRow = moveToRow.prevRow();
20274 prevRowHeightLast = prevRowHeight;
20275 prevRowHeight = prevRow ? prevRow.getHeight() / 2 : 0;
20280 element.addEventListener("touchend
", function (e) {
20281 if (self.checkTimeout) {
20282 clearTimeout(self.checkTimeout);
20286 self.touchMove = false;
20291 MoveRows.prototype._bindMouseMove = function () {
20294 self.table.rowManager.getDisplayRows().forEach(function (row) {
20295 if ((row.type === "row
" || row.type === "group
") && row.modules.moveRow.mousemove) {
20296 row.getElement().addEventListener("mousemove
", row.modules.moveRow.mousemove);
20301 MoveRows.prototype._unbindMouseMove = function () {
20304 self.table.rowManager.getDisplayRows().forEach(function (row) {
20305 if ((row.type === "row
" || row.type === "group
") && row.modules.moveRow.mousemove) {
20306 row.getElement().removeEventListener("mousemove
", row.modules.moveRow.mousemove);
20311 MoveRows.prototype.startMove = function (e, row) {
20312 var element = row.getElement();
20314 this.setStartPosition(e, row);
20318 this.table.element.classList.add("tabulator-block-select
");
20320 //create placeholder
20321 this.placeholderElement.style.width = row.getWidth() + "px
";
20322 this.placeholderElement.style.height = row.getHeight() + "px
";
20324 if (!this.connection) {
20325 element.parentNode.insertBefore(this.placeholderElement, element);
20326 element.parentNode.removeChild(element);
20328 this.table.element.classList.add("tabulator-movingrow-sending
");
20329 this.connectToTables(row);
20332 //create hover element
20333 this.hoverElement = element.cloneNode(true);
20334 this.hoverElement.classList.add("tabulator-moving
");
20336 if (this.connection) {
20337 document.body.appendChild(this.hoverElement);
20338 this.hoverElement.style.left = "0
";
20339 this.hoverElement.style.top = "0
";
20340 this.hoverElement.style.width = this.table.element.clientWidth + "px
";
20341 this.hoverElement.style.whiteSpace = "nowrap
";
20342 this.hoverElement.style.overflow = "hidden
";
20343 this.hoverElement.style.pointerEvents = "none
";
20345 this.table.rowManager.getTableElement().appendChild(this.hoverElement);
20347 this.hoverElement.style.left = "0
";
20348 this.hoverElement.style.top = "0
";
20350 this._bindMouseMove();
20353 document.body.addEventListener("mousemove
", this.moveHover);
20354 document.body.addEventListener("mouseup
", this.endMove);
20359 MoveRows.prototype.setStartPosition = function (e, row) {
20360 var pageX = this.touchMove ? e.touches[0].pageX : e.pageX,
20361 pageY = this.touchMove ? e.touches[0].pageY : e.pageY,
20365 element = row.getElement();
20366 if (this.connection) {
20367 position = element.getBoundingClientRect();
20369 this.startX = position.left - pageX + window.pageXOffset;
20370 this.startY = position.top - pageY + window.pageYOffset;
20372 this.startY = pageY - element.getBoundingClientRect().top;
20376 MoveRows.prototype.endMove = function (e) {
20377 if (!e || e.which === 1 || this.touchMove) {
20378 this._unbindMouseMove();
20380 if (!this.connection) {
20381 this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);
20382 this.placeholderElement.parentNode.removeChild(this.placeholderElement);
20385 this.hoverElement.parentNode.removeChild(this.hoverElement);
20387 this.table.element.classList.remove("tabulator-block-select
");
20390 this.table.rowManager.moveRow(this.moving, this.toRow, this.toRowAfter);
20393 this.moving = false;
20394 this.toRow = false;
20395 this.toRowAfter = false;
20397 document.body.removeEventListener("mousemove
", this.moveHover);
20398 document.body.removeEventListener("mouseup
", this.endMove);
20400 if (this.connection) {
20401 this.table.element.classList.remove("tabulator-movingrow-sending
");
20402 this.disconnectFromTables();
20407 MoveRows.prototype.moveRow = function (row, after) {
20409 this.toRowAfter = after;
20412 MoveRows.prototype.moveHover = function (e) {
20413 if (this.connection) {
20414 this.moveHoverConnections.call(this, e);
20416 this.moveHoverTable.call(this, e);
20420 MoveRows.prototype.moveHoverTable = function (e) {
20421 var rowHolder = this.table.rowManager.getElement(),
20422 scrollTop = rowHolder.scrollTop,
20423 yPos = (this.touchMove ? e.touches[0].pageY : e.pageY) - rowHolder.getBoundingClientRect().top + scrollTop,
20426 this.hoverElement.style.top = yPos - this.startY + "px
";
20429 MoveRows.prototype.moveHoverConnections = function (e) {
20430 this.hoverElement.style.left = this.startX + (this.touchMove ? e.touches[0].pageX : e.pageX) + "px
";
20431 this.hoverElement.style.top = this.startY + (this.touchMove ? e.touches[0].pageY : e.pageY) + "px
";
20434 //establish connection with other tables
20435 MoveRows.prototype.connectToTables = function (row) {
20437 connections = this.table.modules.comms.getConnections(this.connection);
20439 this.table.options.movableRowsSendingStart.call(this.table, connections);
20441 this.table.modules.comms.send(this.connection, "moveRow
", "connect
", {
20446 //disconnect from other tables
20447 MoveRows.prototype.disconnectFromTables = function () {
20449 connections = this.table.modules.comms.getConnections(this.connection);
20451 this.table.options.movableRowsSendingStop.call(this.table, connections);
20453 this.table.modules.comms.send(this.connection, "moveRow
", "disconnect
");
20456 //accept incomming connection
20457 MoveRows.prototype.connect = function (table, row) {
20459 if (!this.connectedTable) {
20460 this.connectedTable = table;
20461 this.connectedRow = row;
20463 this.table.element.classList.add("tabulator-movingrow-receiving
");
20465 self.table.rowManager.getDisplayRows().forEach(function (row) {
20466 if (row.type === "row
" && row.modules.moveRow && row.modules.moveRow.mouseup) {
20467 row.getElement().addEventListener("mouseup
", row.modules.moveRow.mouseup);
20471 self.tableRowDropEvent = self.tableRowDrop.bind(self);
20473 self.table.element.addEventListener("mouseup
", self.tableRowDropEvent);
20475 this.table.options.movableRowsReceivingStart.call(this.table, row, table);
20479 console.warn("Move Row Error - Table cannot accept connection, already connected to table:
", this.connectedTable);
20484 //close incomming connection
20485 MoveRows.prototype.disconnect = function (table) {
20487 if (table === this.connectedTable) {
20488 this.connectedTable = false;
20489 this.connectedRow = false;
20491 this.table.element.classList.remove("tabulator-movingrow-receiving
");
20493 self.table.rowManager.getDisplayRows().forEach(function (row) {
20494 if (row.type === "row
" && row.modules.moveRow && row.modules.moveRow.mouseup) {
20495 row.getElement().removeEventListener("mouseup
", row.modules.moveRow.mouseup);
20499 self.table.element.removeEventListener("mouseup
", self.tableRowDropEvent);
20501 this.table.options.movableRowsReceivingStop.call(this.table, table);
20503 console.warn("Move Row Error - trying to disconnect from non connected table
");
20507 MoveRows.prototype.dropComplete = function (table, row, success) {
20508 var sender = false;
20512 switch (_typeof(this.table.options.movableRowsSender)) {
20514 sender = this.senders[this.table.options.movableRowsSender];
20518 sender = this.table.options.movableRowsSender;
20523 sender.call(this, this.moving.getComponent(), row ? row.getComponent() : undefined, table);
20525 if (this.table.options.movableRowsSender) {
20526 console.warn("Mover Row Error - no matching sender found:
", this.table.options.movableRowsSender);
20530 this.table.options.movableRowsSent.call(this.table, this.moving.getComponent(), row ? row.getComponent() : undefined, table);
20532 this.table.options.movableRowsSentFailed.call(this.table, this.moving.getComponent(), row ? row.getComponent() : undefined, table);
20538 MoveRows.prototype.tableRowDrop = function (e, row) {
20539 var receiver = false,
20542 e.stopImmediatePropagation();
20544 switch (_typeof(this.table.options.movableRowsReceiver)) {
20546 receiver = this.receivers[this.table.options.movableRowsReceiver];
20550 receiver = this.table.options.movableRowsReceiver;
20555 success = receiver.call(this, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);
20557 console.warn("Mover Row Error - no matching receiver found:
", this.table.options.movableRowsReceiver);
20561 this.table.options.movableRowsReceived.call(this.table, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);
20563 this.table.options.movableRowsReceivedFailed.call(this.table, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);
20566 this.table.modules.comms.send(this.connectedTable, "moveRow
", "dropcomplete
", {
20572 MoveRows.prototype.receivers = {
20573 insert: function insert(fromRow, toRow, fromTable) {
20574 this.table.addRow(fromRow.getData(), undefined, toRow);
20578 add: function add(fromRow, toRow, fromTable) {
20579 this.table.addRow(fromRow.getData());
20583 update: function update(fromRow, toRow, fromTable) {
20585 toRow.update(fromRow.getData());
20592 replace: function replace(fromRow, toRow, fromTable) {
20594 this.table.addRow(fromRow.getData(), undefined, toRow);
20603 MoveRows.prototype.senders = {
20604 delete: function _delete(fromRow, toRow, toTable) {
20609 MoveRows.prototype.commsReceived = function (table, action, data) {
20612 return this.connect(table, data.row);
20616 return this.disconnect(table);
20619 case "dropcomplete
":
20620 return this.dropComplete(table, data.row, data.success);
20625 Tabulator.prototype.registerModule("moveRow
", MoveRows);
20626 var Mutator = function Mutator(table) {
20627 this.table = table; //hold Tabulator object
20628 this.allowedTypes = ["", "data
", "edit
", "clipboard
"]; //list of muatation types
20629 this.enabled = true;
20632 //initialize column mutator
20633 Mutator.prototype.initializeColumn = function (column) {
20638 this.allowedTypes.forEach(function (type) {
20639 var key = "mutator
" + (type.charAt(0).toUpperCase() + type.slice(1)),
20642 if (column.definition[key]) {
20643 mutator = self.lookupMutator(column.definition[key]);
20650 params: column.definition[key + "Params
"] || {}
20657 column.modules.mutate = config;
20661 Mutator.prototype.lookupMutator = function (value) {
20662 var mutator = false;
20664 //set column mutator
20665 switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
20667 if (this.mutators[value]) {
20668 mutator = this.mutators[value];
20670 console.warn("Mutator Error - No such mutator found, ignoring:
", value);
20682 //apply mutator to row
20683 Mutator.prototype.transformRow = function (data, type, updatedData) {
20685 key = "mutator
" + (type.charAt(0).toUpperCase() + type.slice(1)),
20688 if (this.enabled) {
20690 self.table.columnManager.traverse(function (column) {
20691 var mutator, params, component;
20693 if (column.modules.mutate) {
20694 mutator = column.modules.mutate[key] || column.modules.mutate.mutator || false;
20696 if (mutator && updatedData) {
20697 value = column.getFieldValue(updatedData);
20699 if (type == "data
" || typeof value !== "undefined
") {
20700 component = column.getComponent();
20701 params = typeof mutator.params === "function
" ? mutator.params(value, data, type, component) : mutator.params;
20702 column.setFieldValue(data, mutator.mutator(value, data, type, params, component));
20712 //apply mutator to new cell value
20713 Mutator.prototype.transformCell = function (cell, value) {
20714 var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator || false,
20718 tempData = Object.assign(tempData, cell.row.getData());
20719 cell.column.setFieldValue(tempData, value);
20720 return mutator.mutator(value, tempData, "edit
", mutator.params, cell.getComponent());
20726 Mutator.prototype.enable = function () {
20727 this.enabled = true;
20730 Mutator.prototype.disable = function () {
20731 this.enabled = false;
20735 Mutator.prototype.mutators = {};
20737 Tabulator.prototype.registerModule("mutator
", Mutator);
20738 var Page = function Page(table) {
20740 this.table = table; //hold Tabulator object
20742 this.mode = "local
";
20743 this.progressiveLoad = false;
20750 this.displayIndex = 0; //index in display pipeline
20752 this.pageSizes = [];
20754 this.createElements();
20757 Page.prototype.createElements = function () {
20761 this.element = document.createElement("span
");
20762 this.element.classList.add("tabulator-paginator
");
20764 this.pagesElement = document.createElement("span
");
20765 this.pagesElement.classList.add("tabulator-pages
");
20767 button = document.createElement("button
");
20768 button.classList.add("tabulator-page
");
20769 button.setAttribute("type
", "button
");
20770 button.setAttribute("role
", "button
");
20771 button.setAttribute("aria-label
", "");
20772 button.setAttribute("title
", "");
20774 this.firstBut = button.cloneNode(true);
20775 this.firstBut.setAttribute("data-page
", "first
");
20777 this.prevBut = button.cloneNode(true);
20778 this.prevBut.setAttribute("data-page
", "prev
");
20780 this.nextBut = button.cloneNode(true);
20781 this.nextBut.setAttribute("data-page
", "next
");
20783 this.lastBut = button.cloneNode(true);
20784 this.lastBut.setAttribute("data-page
", "last
");
20786 if (this.table.options.paginationSizeSelector) {
20787 this.pageSizeSelect = document.createElement("select
");
20788 this.pageSizeSelect.classList.add("tabulator-page-size
");
20792 Page.prototype.generatePageSizeSelectList = function () {
20793 var _this58 = this;
20795 var pageSizes = [];
20797 if (this.pageSizeSelect) {
20799 if (Array.isArray(this.table.options.paginationSizeSelector)) {
20800 pageSizes = this.table.options.paginationSizeSelector;
20801 this.pageSizes = pageSizes;
20803 if (this.pageSizes.indexOf(this.size) == -1) {
20804 pageSizes.unshift(this.size);
20808 if (this.pageSizes.indexOf(this.size) == -1) {
20811 for (var i = 1; i < 5; i++) {
20812 pageSizes.push(this.size * i);
20815 this.pageSizes = pageSizes;
20817 pageSizes = this.pageSizes;
20821 while (this.pageSizeSelect.firstChild) {
20822 this.pageSizeSelect.removeChild(this.pageSizeSelect.firstChild);
20823 }pageSizes.forEach(function (item) {
20824 var itemEl = document.createElement("option
");
20825 itemEl.value = item;
20826 itemEl.innerHTML = item;
20828 _this58.pageSizeSelect.appendChild(itemEl);
20831 this.pageSizeSelect.value = this.size;
20835 //setup pageination
20836 Page.prototype.initialize = function (hidden) {
20840 //update param names
20841 for (var key in self.table.options.paginationDataSent) {
20842 self.paginationDataSentNames[key] = self.table.options.paginationDataSent[key];
20845 for (var _key2 in self.table.options.paginationDataReceived) {
20846 self.paginationDataReceivedNames[_key2] = self.table.options.paginationDataReceived[_key2];
20849 //build pagination element
20851 //bind localizations
20852 self.table.modules.localize.bind("pagination|first
", function (value) {
20853 self.firstBut.innerHTML = value;
20856 self.table.modules.localize.bind("pagination|first_title
", function (value) {
20857 self.firstBut.setAttribute("aria-label
", value);
20858 self.firstBut.setAttribute("title
", value);
20861 self.table.modules.localize.bind("pagination|prev
", function (value) {
20862 self.prevBut.innerHTML = value;
20865 self.table.modules.localize.bind("pagination|prev_title
", function (value) {
20866 self.prevBut.setAttribute("aria-label
", value);
20867 self.prevBut.setAttribute("title
", value);
20870 self.table.modules.localize.bind("pagination|next
", function (value) {
20871 self.nextBut.innerHTML = value;
20874 self.table.modules.localize.bind("pagination|next_title
", function (value) {
20875 self.nextBut.setAttribute("aria-label
", value);
20876 self.nextBut.setAttribute("title
", value);
20879 self.table.modules.localize.bind("pagination|last
", function (value) {
20880 self.lastBut.innerHTML = value;
20883 self.table.modules.localize.bind("pagination|last_title
", function (value) {
20884 self.lastBut.setAttribute("aria-label
", value);
20885 self.lastBut.setAttribute("title
", value);
20889 self.firstBut.addEventListener("click
", function () {
20893 self.prevBut.addEventListener("click
", function () {
20894 self.previousPage();
20897 self.nextBut.addEventListener("click
", function () {
20898 self.nextPage().then(function () {}).catch(function () {});
20901 self.lastBut.addEventListener("click
", function () {
20902 self.setPage(self.max);
20905 if (self.table.options.paginationElement) {
20906 self.element = self.table.options.paginationElement;
20909 if (this.pageSizeSelect) {
20910 pageSelectLabel = document.createElement("label
");
20912 self.table.modules.localize.bind("pagination|page_size
", function (value) {
20913 self.pageSizeSelect.setAttribute("aria-label
", value);
20914 self.pageSizeSelect.setAttribute("title
", value);
20915 pageSelectLabel.innerHTML = value;
20918 self.element.appendChild(pageSelectLabel);
20919 self.element.appendChild(self.pageSizeSelect);
20921 self.pageSizeSelect.addEventListener("change
", function (e) {
20922 self.setPageSize(self.pageSizeSelect.value);
20923 self.setPage(1).then(function () {}).catch(function () {});
20928 self.element.appendChild(self.firstBut);
20929 self.element.appendChild(self.prevBut);
20930 self.element.appendChild(self.pagesElement);
20931 self.element.appendChild(self.nextBut);
20932 self.element.appendChild(self.lastBut);
20934 if (!self.table.options.paginationElement && !hidden) {
20935 self.table.footerManager.append(self.element, self);
20938 //set default values
20939 self.mode = self.table.options.pagination;
20941 self.size = self.table.options.paginationSize || Math.floor(self.table.rowManager.getElement().clientHeight / 24);
20942 // self.page = self.table.options.paginationInitialPage || 1;
20943 self.count = self.table.options.paginationButtonCount;
20945 self.generatePageSizeSelectList();
20948 Page.prototype.initializeProgressive = function (mode) {
20949 this.initialize(true);
20950 this.mode = "progressive_
" + mode;
20951 this.progressiveLoad = true;
20954 Page.prototype.setDisplayIndex = function (index) {
20955 this.displayIndex = index;
20958 Page.prototype.getDisplayIndex = function () {
20959 return this.displayIndex;
20962 //calculate maximum page from number of rows
20963 Page.prototype.setMaxRows = function (rowCount) {
20967 this.max = Math.ceil(rowCount / this.size);
20970 if (this.page > this.max) {
20971 this.page = this.max;
20975 //reset to first page without triggering action
20976 Page.prototype.reset = function (force) {
20977 if (this.mode == "local
" || force) {
20983 //set the maxmum page
20984 Page.prototype.setMaxPage = function (max) {
20986 max = parseInt(max);
20988 this.max = max || 1;
20990 if (this.page > this.max) {
20991 this.page = this.max;
20996 //set current page number
20997 Page.prototype.setPage = function (page) {
20998 var _this59 = this;
21002 return new Promise(function (resolve, reject) {
21004 page = parseInt(page);
21006 if (page > 0 && page <= _this59.max) {
21007 _this59.page = page;
21008 _this59.trigger().then(function () {
21010 }).catch(function () {
21014 if (self.table.options.persistence && self.table.modExists("persistence
", true) && self.table.modules.persistence.config.page) {
21015 self.table.modules.persistence.save("page
");
21018 console.warn("Pagination Error - Requested page is out of range of 1 -
" + _this59.max + ":
", page);
21024 Page.prototype.setPageToRow = function (row) {
21025 var _this60 = this;
21027 return new Promise(function (resolve, reject) {
21029 var rows = _this60.table.rowManager.getDisplayRows(_this60.displayIndex - 1);
21030 var index = rows.indexOf(row);
21033 var page = Math.ceil((index + 1) / _this60.size);
21035 _this60.setPage(page).then(function () {
21037 }).catch(function () {
21041 console.warn("Pagination Error - Requested row is not visible
");
21047 Page.prototype.setPageSize = function (size) {
21048 size = parseInt(size);
21054 if (this.pageSizeSelect) {
21055 // this.pageSizeSelect.value = size;
21056 this.generatePageSizeSelectList();
21059 if (this.table.options.persistence && this.table.modExists("persistence
", true) && this.table.modules.persistence.config.page) {
21060 this.table.modules.persistence.save("page
");
21064 //setup the pagination buttons
21065 Page.prototype._setPageButtons = function () {
21068 var leftSize = Math.floor((this.count - 1) / 2);
21069 var rightSize = Math.ceil((this.count - 1) / 2);
21070 var min = this.max - this.page + leftSize + 1 < this.count ? this.max - this.count + 1 : Math.max(this.page - leftSize, 1);
21071 var max = this.page <= rightSize ? Math.min(this.count, this.max) : Math.min(this.page + rightSize, this.max);
21073 while (self.pagesElement.firstChild) {
21074 self.pagesElement.removeChild(self.pagesElement.firstChild);
21075 }if (self.page == 1) {
21076 self.firstBut.disabled = true;
21077 self.prevBut.disabled = true;
21079 self.firstBut.disabled = false;
21080 self.prevBut.disabled = false;
21083 if (self.page == self.max) {
21084 self.lastBut.disabled = true;
21085 self.nextBut.disabled = true;
21087 self.lastBut.disabled = false;
21088 self.nextBut.disabled = false;
21091 for (var i = min; i <= max; i++) {
21092 if (i > 0 && i <= self.max) {
21093 self.pagesElement.appendChild(self._generatePageButton(i));
21097 this.footerRedraw();
21100 Page.prototype._generatePageButton = function (page) {
21102 button = document.createElement("button
");
21104 button.classList.add("tabulator-page
");
21105 if (page == self.page) {
21106 button.classList.add("active
");
21109 button.setAttribute("type
", "button
");
21110 button.setAttribute("role
", "button
");
21111 button.setAttribute("aria-label
", "Show Page
" + page);
21112 button.setAttribute("title
", "Show Page
" + page);
21113 button.setAttribute("data-page
", page);
21114 button.textContent = page;
21116 button.addEventListener("click
", function (e) {
21117 self.setPage(page);
21124 Page.prototype.previousPage = function () {
21125 var _this61 = this;
21127 return new Promise(function (resolve, reject) {
21128 if (_this61.page > 1) {
21130 _this61.trigger().then(function () {
21132 }).catch(function () {
21136 console.warn("Pagination Error - Previous page would be less than page 1:
", 0);
21143 Page.prototype.nextPage = function () {
21144 var _this62 = this;
21146 return new Promise(function (resolve, reject) {
21147 if (_this62.page < _this62.max) {
21149 _this62.trigger().then(function () {
21151 }).catch(function () {
21155 if (!_this62.progressiveLoad) {
21156 console.warn("Pagination Error - Next page would be greater than maximum page of
" + _this62.max + ":
", _this62.max + 1);
21163 //return current page number
21164 Page.prototype.getPage = function () {
21168 //return max page number
21169 Page.prototype.getPageMax = function () {
21173 Page.prototype.getPageSize = function (size) {
21177 Page.prototype.getMode = function () {
21181 //return appropriate rows for current page
21182 Page.prototype.getRows = function (data) {
21183 var output, start, end;
21185 if (this.mode == "local
") {
21187 start = this.size * (this.page - 1);
21188 end = start + parseInt(this.size);
21190 this._setPageButtons();
21192 for (var i = start; i < end; i++) {
21194 output.push(data[i]);
21201 this._setPageButtons();
21203 return data.slice(0);
21207 Page.prototype.trigger = function () {
21208 var _this63 = this;
21212 return new Promise(function (resolve, reject) {
21214 switch (_this63.mode) {
21216 left = _this63.table.rowManager.scrollLeft;
21218 _this63.table.rowManager.refreshActiveData("page
");
21219 _this63.table.rowManager.scrollHorizontal(left);
21221 _this63.table.options.pageLoaded.call(_this63.table, _this63.getPage());
21226 case "progressive_load
":
21227 case "progressive_scroll
":
21228 _this63.table.modules.ajax.blockActiveRequest();
21229 _this63._getRemotePage().then(function () {
21231 }).catch(function () {
21237 console.warn("Pagination Error - no such pagination mode:
", _this63.mode);
21243 Page.prototype._getRemotePage = function () {
21244 var _this64 = this;
21250 return new Promise(function (resolve, reject) {
21252 if (!self.table.modExists("ajax
", true)) {
21256 //record old params and restore after request has been made
21257 oldParams = Tabulator.prototype.helpers.deepClone(self.table.modules.ajax.getParams() || {});
21258 pageParams = self.table.modules.ajax.getParams();
21260 //configure request params
21261 pageParams[_this64.paginationDataSentNames.page] = self.page;
21263 //set page size if defined
21264 if (_this64.size) {
21265 pageParams[_this64.paginationDataSentNames.size] = _this64.size;
21268 //set sort data if defined
21269 if (_this64.table.options.ajaxSorting && _this64.table.modExists("sort
")) {
21270 var sorters = self.table.modules.sort.getSort();
21272 sorters.forEach(function (item) {
21273 delete item.column;
21276 pageParams[_this64.paginationDataSentNames.sorters] = sorters;
21279 //set filter data if defined
21280 if (_this64.table.options.ajaxFiltering && _this64.table.modExists("filter
")) {
21281 var filters = self.table.modules.filter.getFilters(true, true);
21282 pageParams[_this64.paginationDataSentNames.filters] = filters;
21285 self.table.modules.ajax.setParams(pageParams);
21287 self.table.modules.ajax.sendRequest(_this64.progressiveLoad).then(function (data) {
21288 self._parseRemoteData(data);
21290 }).catch(function (e) {
21294 self.table.modules.ajax.setParams(oldParams);
21298 Page.prototype._parseRemoteData = function (data) {
21304 if (typeof data[this.paginationDataReceivedNames.last_page] === "undefined
") {
21305 console.warn("Remote Pagination Error - Server response missing
'" + this.paginationDataReceivedNames.last_page + "' property
");
21308 if (data[this.paginationDataReceivedNames.data]) {
21309 this.max = parseInt(data[this.paginationDataReceivedNames.last_page]) || 1;
21311 if (this.progressiveLoad) {
21312 switch (this.mode) {
21313 case "progressive_load
":
21314 this.table.rowManager.addRows(data[this.paginationDataReceivedNames.data]);
21315 if (this.page < this.max) {
21316 setTimeout(function () {
21317 self.nextPage().then(function () {}).catch(function () {});
21318 }, self.table.options.ajaxProgressiveLoadDelay);
21322 case "progressive_scroll
":
21323 data = this.table.rowManager.getData().concat(data[this.paginationDataReceivedNames.data]);
21325 this.table.rowManager.setData(data, true);
21327 margin = this.table.options.ajaxProgressiveLoadScrollMargin || this.table.rowManager.element.clientHeight * 2;
21329 if (self.table.rowManager.element.scrollHeight <= self.table.rowManager.element.clientHeight + margin) {
21330 self.nextPage().then(function () {}).catch(function () {});
21335 left = this.table.rowManager.scrollLeft;
21337 this.table.rowManager.setData(data[this.paginationDataReceivedNames.data]);
21339 this.table.rowManager.scrollHorizontal(left);
21341 this.table.columnManager.scrollHorizontal(left);
21343 this.table.options.pageLoaded.call(this.table, this.getPage());
21346 console.warn("Remote Pagination Error - Server response missing
'" + this.paginationDataReceivedNames.data + "' property
");
21350 //handle the footer element being redrawn
21351 Page.prototype.footerRedraw = function () {
21352 var footer = this.table.footerManager.element;
21354 if (Math.ceil(footer.clientWidth) - footer.scrollWidth < 0) {
21355 this.pagesElement.style.display = 'none';
21357 this.pagesElement.style.display = '';
21359 if (Math.ceil(footer.clientWidth) - footer.scrollWidth < 0) {
21360 this.pagesElement.style.display = 'none';
21365 //set the paramter names for pagination requests
21366 Page.prototype.paginationDataSentNames = {
21369 "sorters
": "sorters
",
21370 // "sort_dir
":"sort_dir
",
21371 "filters
": "filters
"
21372 // "filter_value
":"filter_value
",
21373 // "filter_type
":"filter_type
",
21376 //set the property names for pagination responses
21377 Page.prototype.paginationDataReceivedNames = {
21378 "current_page
": "current_page
",
21379 "last_page
": "last_page
",
21383 Tabulator.prototype.registerModule("page
", Page);
21385 var Persistence = function Persistence(table) {
21386 this.table = table; //hold Tabulator object
21389 // this.persistProps = ["field
", "width
", "visible
"];
21390 this.defWatcherBlock = false;
21392 this.readFunc = false;
21393 this.writeFunc = false;
21396 // Test for whether localStorage is available for use.
21397 Persistence.prototype.localStorageTest = function () {
21398 var testKey = "_tabulator_test
";
21401 window.localStorage.setItem(testKey, testKey);
21402 window.localStorage.removeItem(testKey);
21410 Persistence.prototype.initialize = function () {
21411 //determine persistent layout storage type
21413 var mode = this.table.options.persistenceMode,
21414 id = this.table.options.persistenceID,
21417 this.mode = mode !== true ? mode : this.localStorageTest() ? "local
" : "cookie
";
21419 if (this.table.options.persistenceReaderFunc) {
21420 if (typeof this.table.options.persistenceReaderFunc === "function
") {
21421 this.readFunc = this.table.options.persistenceReaderFunc;
21423 if (this.readers[this.table.options.persistenceReaderFunc]) {
21424 this.readFunc = this.readers[this.table.options.persistenceReaderFunc];
21426 console.warn("Persistence Read Error - invalid reader set
", this.table.options.persistenceReaderFunc);
21430 if (this.readers[this.mode]) {
21431 this.readFunc = this.readers[this.mode];
21433 console.warn("Persistence Read Error - invalid reader set
", this.mode);
21437 if (this.table.options.persistenceWriterFunc) {
21438 if (typeof this.table.options.persistenceWriterFunc === "function
") {
21439 this.writeFunc = this.table.options.persistenceWriterFunc;
21441 if (this.readers[this.table.options.persistenceWriterFunc]) {
21442 this.writeFunc = this.readers[this.table.options.persistenceWriterFunc];
21444 console.warn("Persistence Write Error - invalid reader set
", this.table.options.persistenceWriterFunc);
21448 if (this.writers[this.mode]) {
21449 this.writeFunc = this.writers[this.mode];
21451 console.warn("Persistence Write Error - invalid writer set
", this.mode);
21456 this.id = "tabulator-
" + (id || this.table.element.getAttribute("id
") || "");
21459 sort: this.table.options.persistence === true || this.table.options.persistence.sort,
21460 filter: this.table.options.persistence === true || this.table.options.persistence.filter,
21461 group: this.table.options.persistence === true || this.table.options.persistence.group,
21462 page: this.table.options.persistence === true || this.table.options.persistence.page,
21463 columns: this.table.options.persistence === true ? ["title
", "width
", "visible
"] : this.table.options.persistence.columns
21466 //load pagination data if needed
21467 if (this.config.page) {
21468 retreivedData = this.retreiveData("page
");
21470 if (retreivedData) {
21471 if (typeof retreivedData.paginationSize !== "undefined
" && (this.config.page === true || this.config.page.size)) {
21472 this.table.options.paginationSize = retreivedData.paginationSize;
21475 if (typeof retreivedData.paginationInitialPage !== "undefined
" && (this.config.page === true || this.config.page.page)) {
21476 this.table.options.paginationInitialPage = retreivedData.paginationInitialPage;
21481 //load group data if needed
21482 if (this.config.group) {
21483 retreivedData = this.retreiveData("group
");
21485 if (retreivedData) {
21486 if (typeof retreivedData.groupBy !== "undefined
" && (this.config.group === true || this.config.group.groupBy)) {
21487 this.table.options.groupBy = retreivedData.groupBy;
21489 if (typeof retreivedData.groupStartOpen !== "undefined
" && (this.config.group === true || this.config.group.groupStartOpen)) {
21490 this.table.options.groupStartOpen = retreivedData.groupStartOpen;
21492 if (typeof retreivedData.groupHeader !== "undefined
" && (this.config.group === true || this.config.group.groupHeader)) {
21493 this.table.options.groupHeader = retreivedData.groupHeader;
21499 Persistence.prototype.initializeColumn = function (column) {
21504 if (this.config.columns) {
21505 this.defWatcherBlock = true;
21507 def = column.getDefinition();
21509 keys = this.config.columns === true ? Object.keys(def) : this.config.columns;
21511 keys.forEach(function (key) {
21512 var props = Object.getOwnPropertyDescriptor(def, key);
21513 var value = def[key];
21515 Object.defineProperty(def, key, {
21516 set: function set(newValue) {
21519 if (!self.defWatcherBlock) {
21520 self.save("columns
");
21524 props.set(newValue);
21527 get: function get() {
21537 this.defWatcherBlock = false;
21541 //load saved definitions
21542 Persistence.prototype.load = function (type, current) {
21543 var data = this.retreiveData(type);
21546 data = data ? this.mergeDefinition(current, data) : current;
21552 //retreive data from memory
21553 Persistence.prototype.retreiveData = function (type) {
21554 return this.readFunc ? this.readFunc(this.id, type) : false;
21557 //merge old and new column definitions
21558 Persistence.prototype.mergeDefinition = function (oldCols, newCols) {
21562 // oldCols = oldCols || [];
21563 newCols = newCols || [];
21565 newCols.forEach(function (column, to) {
21567 var from = self._findColumn(oldCols, column),
21572 if (self.config.columns === true || self.config.columns == undefined) {
21573 keys = Object.keys(from);
21574 keys.push("width
");
21576 keys = self.config.columns;
21579 keys.forEach(function (key) {
21580 if (typeof column[key] !== "undefined
") {
21581 from[key] = column[key];
21585 if (from.columns) {
21586 from.columns = self.mergeDefinition(from.columns, column.columns);
21593 oldCols.forEach(function (column, i) {
21594 var from = self._findColumn(newCols, column);
21596 if (output.length > i) {
21597 output.splice(i, 0, column);
21599 output.push(column);
21607 //find matching columns
21608 Persistence.prototype._findColumn = function (columns, subject) {
21609 var type = subject.columns ? "group
" : subject.field ? "field
" : "object
";
21611 return columns.find(function (col) {
21614 return col.title === subject.title && col.columns.length === subject.columns.length;
21618 return col.field === subject.field;
21622 return col === subject;
21629 Persistence.prototype.save = function (type) {
21634 data = this.parseColumns(this.table.columnManager.getColumns());
21638 data = this.table.modules.filter.getFilters();
21642 data = this.validateSorters(this.table.modules.sort.getSort());
21646 data = this.getGroupConfig();
21650 data = this.getPageConfig();
21654 if (this.writeFunc) {
21655 this.writeFunc(this.id, type, data);
21659 //ensure sorters contain no function data
21660 Persistence.prototype.validateSorters = function (data) {
21661 data.forEach(function (item) {
21662 item.column = item.field;
21669 Persistence.prototype.getGroupConfig = function () {
21670 if (this.config.group) {
21671 if (this.config.group === true || this.config.group.groupBy) {
21672 data.groupBy = this.table.options.groupBy;
21675 if (this.config.group === true || this.config.group.groupStartOpen) {
21676 data.groupStartOpen = this.table.options.groupStartOpen;
21679 if (this.config.group === true || this.config.group.groupHeader) {
21680 data.groupHeader = this.table.options.groupHeader;
21687 Persistence.prototype.getPageConfig = function () {
21690 if (this.config.page) {
21691 if (this.config.page === true || this.config.page.size) {
21692 data.paginationSize = this.table.modules.page.getPageSize();
21695 if (this.config.page === true || this.config.page.page) {
21696 data.paginationInitialPage = this.table.modules.page.getPage();
21703 //parse columns for data to store
21704 Persistence.prototype.parseColumns = function (columns) {
21708 columns.forEach(function (column) {
21710 colDef = column.getDefinition(),
21713 if (column.isGroup) {
21714 defStore.title = colDef.title;
21715 defStore.columns = self.parseColumns(column.getColumns());
21717 defStore.field = column.getField();
21719 if (self.config.columns === true || self.config.columns == undefined) {
21720 keys = Object.keys(colDef);
21721 keys.push("width
");
21723 keys = self.config.columns;
21726 keys.forEach(function (key) {
21730 defStore.width = column.getWidth();
21733 defStore.visible = column.visible;
21737 defStore[key] = colDef[key];
21742 definitions.push(defStore);
21745 return definitions;
21748 // read peristence information from storage
21749 Persistence.prototype.readers = {
21750 local: function local(id, type) {
21751 var data = localStorage.getItem(id + "-
" + type);
21753 return data ? JSON.parse(data) : false;
21755 cookie: function cookie(id, type) {
21756 var cookie = document.cookie,
21757 key = id + "-
" + type,
21758 cookiePos = cookie.indexOf(key + "=
"),
21761 //if cookie exists, decode and load column data into tabulator
21762 if (cookiePos > -1) {
21763 cookie = cookie.substr(cookiePos);
21765 end = cookie.indexOf(";
");
21768 cookie = cookie.substr(0, end);
21771 data = cookie.replace(key + "=
", "");
21774 return data ? JSON.parse(data) : false;
21778 //write persistence information to storage
21779 Persistence.prototype.writers = {
21780 local: function local(id, type, data) {
21781 localStorage.setItem(id + "-
" + type, JSON.stringify(data));
21783 cookie: function cookie(id, type, data) {
21784 var expireDate = new Date();
21786 expireDate.setDate(expireDate.getDate() + 10000);
21788 document.cookie = id + "_
" + type + "=
" + JSON.stringify(data) + "; expires=
" + expireDate.toUTCString();
21792 Tabulator.prototype.registerModule("persistence
", Persistence);
21794 var Print = function Print(table) {
21795 this.table = table; //hold Tabulator object
21796 this.element = false;
21797 this.manualBlock = false;
21800 Print.prototype.initialize = function () {
21801 window.addEventListener("beforeprint
", this.replaceTable.bind(this));
21802 window.addEventListener("afterprint
", this.cleanup.bind(this));
21805 Print.prototype.replaceTable = function () {
21806 if (!this.manualBlock) {
21807 this.element = document.createElement("div
");
21808 this.element.classList.add("tabulator-print-table
");
21810 this.element.appendChild(this.table.modules.htmlTableExport.genereateTable(this.table.options.printConfig, this.table.options.printCopyStyle, this.table.options.printVisibleRows, "print
"));
21812 this.table.element.style.display = "none
";
21814 this.table.element.parentNode.insertBefore(this.element, this.table.element);
21818 Print.prototype.cleanup = function () {
21819 document.body.classList.remove("tabulator-print-fullscreen-hide
");
21821 if (this.element && this.element.parentNode) {
21822 this.element.parentNode.removeChild(this.element);
21823 this.table.element.style.display = "";
21827 Print.prototype.printFullscreen = function (visible, style, config) {
21828 var scrollX = window.scrollX,
21829 scrollY = window.scrollY,
21830 headerEl = document.createElement("div
"),
21831 footerEl = document.createElement("div
"),
21832 tableEl = this.table.modules.htmlTableExport.genereateTable(typeof config != "undefined
" ? config : this.table.options.printConfig, typeof style != "undefined
" ? style : this.table.options.printCopyStyle, visible, "print
"),
21836 this.manualBlock = true;
21838 this.element = document.createElement("div
");
21839 this.element.classList.add("tabulator-print-fullscreen
");
21841 if (this.table.options.printHeader) {
21842 headerEl.classList.add("tabulator-print-header
");
21844 headerContent = typeof this.table.options.printHeader == "function" ? this.table.options.printHeader.call(this.table) : this.table.options.printHeader;
21846 if (typeof headerContent == "string") {
21847 headerEl.innerHTML = headerContent;
21849 headerEl.appendChild(headerContent);
21852 this.element.appendChild(headerEl);
21855 this.element.appendChild(tableEl);
21857 if (this.table.options.printFooter) {
21858 footerEl.classList.add("tabulator-print-footer
");
21860 footerContent = typeof this.table.options.printFooter == "function" ? this.table.options.printFooter.call(this.table) : this.table.options.printFooter;
21862 if (typeof footerContent == "string") {
21863 footerEl.innerHTML = footerContent;
21865 footerEl.appendChild(footerContent);
21868 this.element.appendChild(footerEl);
21871 document.body.classList.add("tabulator-print-fullscreen-hide
");
21872 document.body.appendChild(this.element);
21874 if (this.table.options.printFormatter) {
21875 this.table.options.printFormatter(this.element, tableEl);
21882 window.scrollTo(scrollX, scrollY);
21884 this.manualBlock = false;
21887 Tabulator.prototype.registerModule("print
", Print);
21888 var ReactiveData = function ReactiveData(table) {
21889 this.table = table; //hold Tabulator object
21891 this.blocked = false; //block reactivity while performing update
21892 this.origFuncs = {}; // hold original data array functions to allow replacement after data is done with
21893 this.currentVersion = 0;
21896 ReactiveData.prototype.watchData = function (data) {
21901 this.currentVersion++;
21903 version = this.currentVersion;
21905 self.unwatchData();
21909 //override array push function
21910 self.origFuncs.push = data.push;
21912 Object.defineProperty(self.data, "push
", {
21914 configurable: true,
21915 value: function value() {
21916 var args = Array.from(arguments);
21918 if (!self.blocked && version === self.currentVersion) {
21919 args.forEach(function (arg) {
21920 self.table.rowManager.addRowActual(arg, false);
21924 return self.origFuncs.push.apply(data, arguments);
21928 //override array unshift function
21929 self.origFuncs.unshift = data.unshift;
21931 Object.defineProperty(self.data, "unshift
", {
21933 configurable: true,
21934 value: function value() {
21935 var args = Array.from(arguments);
21937 if (!self.blocked && version === self.currentVersion) {
21938 args.forEach(function (arg) {
21939 self.table.rowManager.addRowActual(arg, true);
21943 return self.origFuncs.unshift.apply(data, arguments);
21947 //override array shift function
21948 self.origFuncs.shift = data.shift;
21950 Object.defineProperty(self.data, "shift
", {
21952 configurable: true,
21953 value: function value() {
21956 if (!self.blocked && version === self.currentVersion) {
21957 if (self.data.length) {
21958 row = self.table.rowManager.getRowFromDataObject(self.data[0]);
21961 row.deleteActual();
21966 return self.origFuncs.shift.call(data);
21970 //override array pop function
21971 self.origFuncs.pop = data.pop;
21973 Object.defineProperty(self.data, "pop
", {
21975 configurable: true,
21976 value: function value() {
21978 if (!self.blocked && version === self.currentVersion) {
21979 if (self.data.length) {
21980 row = self.table.rowManager.getRowFromDataObject(self.data[self.data.length - 1]);
21983 row.deleteActual();
21987 return self.origFuncs.pop.call(data);
21991 //override array splice function
21992 self.origFuncs.splice = data.splice;
21994 Object.defineProperty(self.data, "splice
", {
21996 configurable: true,
21997 value: function value() {
21998 var args = Array.from(arguments),
21999 start = args[0] < 0 ? data.length + args[0] : args[0],
22001 newRows = args[2] ? args.slice(2) : false,
22004 if (!self.blocked && version === self.currentVersion) {
22008 startRow = data[start] ? self.table.rowManager.getRowFromDataObject(data[start]) : false;
22011 newRows.forEach(function (rowData) {
22012 self.table.rowManager.addRowActual(rowData, true, startRow, true);
22015 newRows = newRows.slice().reverse();
22017 newRows.forEach(function (rowData) {
22018 self.table.rowManager.addRowActual(rowData, true, false, true);
22023 //delete removed rows
22025 var oldRows = data.slice(start, typeof args[1] === "undefined
" ? args[1] : start + end);
22027 oldRows.forEach(function (rowData, i) {
22028 var row = self.table.rowManager.getRowFromDataObject(rowData);
22031 row.deleteActual(i !== oldRows.length - 1);
22036 if (newRows || end !== 0) {
22037 self.table.rowManager.reRenderInPosition();
22041 return self.origFuncs.splice.apply(data, arguments);
22046 ReactiveData.prototype.unwatchData = function () {
22047 if (this.data !== false) {
22048 for (var key in this.origFuncs) {
22049 Object.defineProperty(this.data, key, {
22051 configurable: true,
22053 value: this.origFuncs.key
22059 ReactiveData.prototype.watchRow = function (row) {
22061 data = row.getData();
22063 this.blocked = true;
22065 for (var key in data) {
22066 this.watchKey(row, data, key);
22069 this.blocked = false;
22072 ReactiveData.prototype.watchKey = function (row, data, key) {
22074 props = Object.getOwnPropertyDescriptor(data, key),
22076 version = this.currentVersion;
22078 Object.defineProperty(data, key, {
22079 set: function set(newValue) {
22081 if (!self.blocked && version === self.currentVersion) {
22083 update[key] = newValue;
22084 row.updateData(update);
22088 props.set(newValue);
22091 get: function get() {
22102 ReactiveData.prototype.unwatchRow = function (row) {
22103 var data = row.getData();
22105 for (var key in data) {
22106 Object.defineProperty(data, key, {
22112 ReactiveData.prototype.block = function () {
22113 this.blocked = true;
22116 ReactiveData.prototype.unblock = function () {
22117 this.blocked = false;
22120 Tabulator.prototype.registerModule("reactiveData
", ReactiveData);
22122 var ResizeColumns = function ResizeColumns(table) {
22123 this.table = table; //hold Tabulator object
22124 this.startColumn = false;
22125 this.startX = false;
22126 this.startWidth = false;
22127 this.handle = null;
22128 this.prevHandle = null;
22131 ResizeColumns.prototype.initializeColumn = function (type, column, element) {
22133 variableHeight = false,
22134 mode = this.table.options.resizableColumns;
22136 //set column resize mode
22137 if (type === "header
") {
22138 variableHeight = column.definition.formatter == "textarea
" || column.definition.variableHeight;
22139 column.modules.resize = { variableHeight: variableHeight };
22142 if (mode === true || mode == type) {
22144 var handle = document.createElement('div');
22145 handle.className = "tabulator-col-resize-handle
";
22147 var prevHandle = document.createElement('div');
22148 prevHandle.className = "tabulator-col-resize-handle prev
";
22150 handle.addEventListener("click
", function (e) {
22151 e.stopPropagation();
22154 var handleDown = function handleDown(e) {
22155 var nearestColumn = column.getLastColumn();
22157 if (nearestColumn && self._checkResizability(nearestColumn)) {
22158 self.startColumn = column;
22159 self._mouseDown(e, nearestColumn, handle);
22163 handle.addEventListener("mousedown
", handleDown);
22164 handle.addEventListener("touchstart
", handleDown, { passive: true });
22166 //reszie column on double click
22167 handle.addEventListener("dblclick
", function (e) {
22168 var col = column.getLastColumn();
22170 if (col && self._checkResizability(col)) {
22171 e.stopPropagation();
22172 col.reinitializeWidth(true);
22176 prevHandle.addEventListener("click
", function (e) {
22177 e.stopPropagation();
22180 var prevHandleDown = function prevHandleDown(e) {
22181 var nearestColumn, colIndex, prevColumn;
22183 nearestColumn = column.getFirstColumn();
22185 if (nearestColumn) {
22186 colIndex = self.table.columnManager.findColumnIndex(nearestColumn);
22187 prevColumn = colIndex > 0 ? self.table.columnManager.getColumnByIndex(colIndex - 1) : false;
22189 if (prevColumn && self._checkResizability(prevColumn)) {
22190 self.startColumn = column;
22191 self._mouseDown(e, prevColumn, prevHandle);
22196 prevHandle.addEventListener("mousedown
", prevHandleDown);
22197 prevHandle.addEventListener("touchstart
", prevHandleDown, { passive: true });
22199 //resize column on double click
22200 prevHandle.addEventListener("dblclick
", function (e) {
22201 var nearestColumn, colIndex, prevColumn;
22203 nearestColumn = column.getFirstColumn();
22205 if (nearestColumn) {
22206 colIndex = self.table.columnManager.findColumnIndex(nearestColumn);
22207 prevColumn = colIndex > 0 ? self.table.columnManager.getColumnByIndex(colIndex - 1) : false;
22209 if (prevColumn && self._checkResizability(prevColumn)) {
22210 e.stopPropagation();
22211 prevColumn.reinitializeWidth(true);
22216 element.appendChild(handle);
22217 element.appendChild(prevHandle);
22221 ResizeColumns.prototype._checkResizability = function (column) {
22222 return typeof column.definition.resizable != "undefined
" ? column.definition.resizable : this.table.options.resizableColumns;
22225 ResizeColumns.prototype._mouseDown = function (e, column, handle) {
22228 self.table.element.classList.add("tabulator-block-select
");
22230 function mouseMove(e) {
22231 // self.table.columnManager.tempScrollBlock();
22233 column.setWidth(self.startWidth + ((typeof e.screenX === "undefined
" ? e.touches[0].screenX : e.screenX) - self.startX));
22235 if (!self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight) {
22236 column.checkCellHeights();
22240 function mouseUp(e) {
22242 //block editor from taking action while resizing is taking place
22243 if (self.startColumn.modules.edit) {
22244 self.startColumn.modules.edit.blocked = false;
22247 if (self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight) {
22248 column.checkCellHeights();
22251 document.body.removeEventListener("mouseup
", mouseUp);
22252 document.body.removeEventListener("mousemove
", mouseMove);
22254 handle.removeEventListener("touchmove
", mouseMove);
22255 handle.removeEventListener("touchend
", mouseUp);
22257 self.table.element.classList.remove("tabulator-block-select
");
22259 if (self.table.options.persistence && self.table.modExists("persistence
", true) && self.table.modules.persistence.config.columns) {
22260 self.table.modules.persistence.save("columns
");
22263 self.table.options.columnResized.call(self.table, column.getComponent());
22266 e.stopPropagation(); //prevent resize from interfereing with movable columns
22268 //block editor from taking action while resizing is taking place
22269 if (self.startColumn.modules.edit) {
22270 self.startColumn.modules.edit.blocked = true;
22273 self.startX = typeof e.screenX === "undefined
" ? e.touches[0].screenX : e.screenX;
22274 self.startWidth = column.getWidth();
22276 document.body.addEventListener("mousemove
", mouseMove);
22277 document.body.addEventListener("mouseup
", mouseUp);
22278 handle.addEventListener("touchmove
", mouseMove, { passive: true });
22279 handle.addEventListener("touchend
", mouseUp);
22282 Tabulator.prototype.registerModule("resizeColumns
", ResizeColumns);
22283 var ResizeRows = function ResizeRows(table) {
22284 this.table = table; //hold Tabulator object
22285 this.startColumn = false;
22286 this.startY = false;
22287 this.startHeight = false;
22288 this.handle = null;
22289 this.prevHandle = null;
22292 ResizeRows.prototype.initializeRow = function (row) {
22294 rowEl = row.getElement();
22296 var handle = document.createElement('div');
22297 handle.className = "tabulator-row-resize-handle
";
22299 var prevHandle = document.createElement('div');
22300 prevHandle.className = "tabulator-row-resize-handle prev
";
22302 handle.addEventListener("click
", function (e) {
22303 e.stopPropagation();
22306 var handleDown = function handleDown(e) {
22307 self.startRow = row;
22308 self._mouseDown(e, row, handle);
22311 handle.addEventListener("mousedown
", handleDown);
22312 handle.addEventListener("touchstart
", handleDown, { passive: true });
22314 prevHandle.addEventListener("click
", function (e) {
22315 e.stopPropagation();
22318 var prevHandleDown = function prevHandleDown(e) {
22319 var prevRow = self.table.rowManager.prevDisplayRow(row);
22322 self.startRow = prevRow;
22323 self._mouseDown(e, prevRow, prevHandle);
22327 prevHandle.addEventListener("mousedown
", prevHandleDown);
22328 prevHandle.addEventListener("touchstart
", prevHandleDown, { passive: true });
22330 rowEl.appendChild(handle);
22331 rowEl.appendChild(prevHandle);
22334 ResizeRows.prototype._mouseDown = function (e, row, handle) {
22337 self.table.element.classList.add("tabulator-block-select
");
22339 function mouseMove(e) {
22340 row.setHeight(self.startHeight + ((typeof e.screenY === "undefined
" ? e.touches[0].screenY : e.screenY) - self.startY));
22343 function mouseUp(e) {
22345 // //block editor from taking action while resizing is taking place
22346 // if(self.startColumn.modules.edit){
22347 // self.startColumn.modules.edit.blocked = false;
22350 document.body.removeEventListener("mouseup
", mouseMove);
22351 document.body.removeEventListener("mousemove
", mouseMove);
22353 handle.removeEventListener("touchmove
", mouseMove);
22354 handle.removeEventListener("touchend
", mouseUp);
22356 self.table.element.classList.remove("tabulator-block-select
");
22358 self.table.options.rowResized.call(this.table, row.getComponent());
22361 e.stopPropagation(); //prevent resize from interfereing with movable columns
22363 //block editor from taking action while resizing is taking place
22364 // if(self.startColumn.modules.edit){
22365 // self.startColumn.modules.edit.blocked = true;
22368 self.startY = typeof e.screenY === "undefined
" ? e.touches[0].screenY : e.screenY;
22369 self.startHeight = row.getHeight();
22371 document.body.addEventListener("mousemove
", mouseMove);
22372 document.body.addEventListener("mouseup
", mouseUp);
22374 handle.addEventListener("touchmove
", mouseMove, { passive: true });
22375 handle.addEventListener("touchend
", mouseUp);
22378 Tabulator.prototype.registerModule("resizeRows
", ResizeRows);
22379 var ResizeTable = function ResizeTable(table) {
22380 this.table = table; //hold Tabulator object
22381 this.binding = false;
22382 this.observer = false;
22385 ResizeTable.prototype.initialize = function (row) {
22386 var table = this.table,
22389 if (typeof ResizeObserver !== "undefined
" && table.rowManager.getRenderMode() === "virtual") {
22390 this.observer = new ResizeObserver(function (entry) {
22391 if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) {
22396 this.observer.observe(table.element);
22398 this.binding = function () {
22399 if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) {
22404 window.addEventListener("resize
", this.binding);
22408 ResizeTable.prototype.clearBindings = function (row) {
22409 if (this.binding) {
22410 window.removeEventListener("resize
", this.binding);
22413 if (this.observer) {
22414 this.observer.unobserve(this.table.element);
22418 Tabulator.prototype.registerModule("resizeTable
", ResizeTable);
22419 var ResponsiveLayout = function ResponsiveLayout(table) {
22420 this.table = table; //hold Tabulator object
22422 this.hiddenColumns = [];
22425 this.collapseFormatter = [];
22426 this.collapseStartOpen = true;
22427 this.collapseHandleColumn = false;
22430 //generate resposive columns list
22431 ResponsiveLayout.prototype.initialize = function () {
22435 this.mode = this.table.options.responsiveLayout;
22436 this.collapseFormatter = this.table.options.responsiveLayoutCollapseFormatter || this.formatCollapsedData;
22437 this.collapseStartOpen = this.table.options.responsiveLayoutCollapseStartOpen;
22438 this.hiddenColumns = [];
22440 //detemine level of responsivity for each column
22441 this.table.columnManager.columnsByIndex.forEach(function (column, i) {
22442 if (column.modules.responsive) {
22443 if (column.modules.responsive.order && column.modules.responsive.visible) {
22444 column.modules.responsive.index = i;
22445 columns.push(column);
22447 if (!column.visible && self.mode === "collapse
") {
22448 self.hiddenColumns.push(column);
22454 //sort list by responsivity
22455 columns = columns.reverse();
22456 columns = columns.sort(function (a, b) {
22457 var diff = b.modules.responsive.order - a.modules.responsive.order;
22458 return diff || b.modules.responsive.index - a.modules.responsive.index;
22461 this.columns = columns;
22463 if (this.mode === "collapse
") {
22464 this.generateCollapsedContent();
22467 //assign collapse column
22468 for (var _iterator = this.table.columnManager.columnsByIndex, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
22472 if (_i >= _iterator.length) break;
22473 _ref = _iterator[_i++];
22475 _i = _iterator.next();
22476 if (_i.done) break;
22482 if (col.definition.formatter == "responsiveCollapse
") {
22483 this.collapseHandleColumn = col;
22488 if (this.collapseHandleColumn) {
22489 if (this.hiddenColumns.length) {
22490 this.collapseHandleColumn.show();
22492 this.collapseHandleColumn.hide();
22497 //define layout information
22498 ResponsiveLayout.prototype.initializeColumn = function (column) {
22499 var def = column.getDefinition();
22501 column.modules.responsive = { order: typeof def.responsive === "undefined
" ? 1 : def.responsive, visible: def.visible === false ? false : true };
22504 ResponsiveLayout.prototype.initializeRow = function (row) {
22507 if (row.type !== "calc
") {
22508 el = document.createElement("div
");
22509 el.classList.add("tabulator-responsive-collapse
");
22511 row.modules.responsiveLayout = {
22513 open: this.collapseStartOpen
22516 if (!this.collapseStartOpen) {
22517 el.style.display = 'none';
22522 ResponsiveLayout.prototype.layoutRow = function (row) {
22523 var rowEl = row.getElement();
22525 if (row.modules.responsiveLayout) {
22526 rowEl.appendChild(row.modules.responsiveLayout.element);
22527 this.generateCollapsedRowContent(row);
22531 //update column visibility
22532 ResponsiveLayout.prototype.updateColumnVisibility = function (column, visible) {
22534 if (column.modules.responsive) {
22535 column.modules.responsive.visible = visible;
22540 ResponsiveLayout.prototype.hideColumn = function (column) {
22541 var colCount = this.hiddenColumns.length;
22543 column.hide(false, true);
22545 if (this.mode === "collapse
") {
22546 this.hiddenColumns.unshift(column);
22547 this.generateCollapsedContent();
22549 if (this.collapseHandleColumn && !colCount) {
22550 this.collapseHandleColumn.show();
22555 ResponsiveLayout.prototype.showColumn = function (column) {
22558 column.show(false, true);
22559 //set column width to prevent calculation loops on uninitialized columns
22560 column.setWidth(column.getWidth());
22562 if (this.mode === "collapse
") {
22563 index = this.hiddenColumns.indexOf(column);
22566 this.hiddenColumns.splice(index, 1);
22569 this.generateCollapsedContent();
22571 if (this.collapseHandleColumn && !this.hiddenColumns.length) {
22572 this.collapseHandleColumn.hide();
22577 //redraw columns to fit space
22578 ResponsiveLayout.prototype.update = function () {
22584 var width = self.table.modules.layout.getMode() == "fitColumns
" ? self.table.columnManager.getFlexBaseWidth() : self.table.columnManager.getWidth();
22586 var diff = (self.table.options.headerVisible ? self.table.columnManager.element.clientWidth : self.table.element.clientWidth) - width;
22589 //table is too wide
22590 var column = self.columns[self.index];
22593 self.hideColumn(column);
22600 //table has spare space
22601 var _column = self.columns[self.index - 1];
22605 if (diff >= _column.getWidth()) {
22606 self.showColumn(_column);
22619 if (!self.table.rowManager.activeRowsCount) {
22620 self.table.rowManager.renderEmptyScroll();
22625 ResponsiveLayout.prototype.generateCollapsedContent = function () {
22627 rows = this.table.rowManager.getDisplayRows();
22629 rows.forEach(function (row) {
22630 self.generateCollapsedRowContent(row);
22634 ResponsiveLayout.prototype.generateCollapsedRowContent = function (row) {
22637 if (row.modules.responsiveLayout) {
22638 el = row.modules.responsiveLayout.element;
22640 while (el.firstChild) {
22641 el.removeChild(el.firstChild);
22642 }contents = this.collapseFormatter(this.generateCollapsedRowData(row));
22644 el.appendChild(contents);
22649 ResponsiveLayout.prototype.generateCollapsedRowData = function (row) {
22651 data = row.getData(),
22655 this.hiddenColumns.forEach(function (column) {
22656 var value = column.getFieldValue(data);
22658 if (column.definition.title && column.field) {
22659 if (column.modules.format && self.table.options.responsiveLayoutCollapseUseFormatters) {
22661 mockCellComponent = {
22664 getValue: function getValue() {
22667 getData: function getData() {
22670 getElement: function getElement() {
22671 return document.createElement("div
");
22673 getRow: function getRow() {
22674 return row.getComponent();
22676 getColumn: function getColumn() {
22677 return column.getComponent();
22682 title: column.definition.title,
22683 value: column.modules.format.formatter.call(self.table.modules.format, mockCellComponent, column.modules.format.params)
22687 title: column.definition.title,
22697 ResponsiveLayout.prototype.formatCollapsedData = function (data) {
22698 var list = document.createElement("table
"),
22701 data.forEach(function (item) {
22702 var div = document.createElement("div
");
22704 if (item.value instanceof Node) {
22705 div.appendChild(item.value);
22706 item.value = div.innerHTML;
22709 listContents += "<tr><td><strong>
" + item.title + "</strong></td><td>
" + item.value + "</td></tr>
";
22712 list.innerHTML = listContents;
22714 return Object.keys(data).length ? list : "";
22717 Tabulator.prototype.registerModule("responsiveLayout
", ResponsiveLayout);
22719 var SelectRow = function SelectRow(table) {
22720 this.table = table; //hold Tabulator object
22721 this.selecting = false; //flag selecting in progress
22722 this.lastClickedRow = false; //last clicked row
22723 this.selectPrev = []; //hold previously selected element for drag drop selection
22724 this.selectedRows = []; //hold selected rows
22725 this.headerCheckboxElement = null; // hold header select element
22728 SelectRow.prototype.clearSelectionData = function (silent) {
22729 this.selecting = false;
22730 this.lastClickedRow = false;
22731 this.selectPrev = [];
22732 this.selectedRows = [];
22735 this._rowSelectionChanged();
22739 SelectRow.prototype.initializeRow = function (row) {
22741 element = row.getElement();
22743 // trigger end of row selection
22744 var endSelect = function endSelect() {
22746 setTimeout(function () {
22747 self.selecting = false;
22750 document.body.removeEventListener("mouseup
", endSelect);
22753 row.modules.select = { selected: false };
22755 //set row selection class
22756 if (self.table.options.selectableCheck.call(this.table, row.getComponent())) {
22757 element.classList.add("tabulator-selectable
");
22758 element.classList.remove("tabulator-unselectable
");
22760 if (self.table.options.selectable && self.table.options.selectable != "highlight
") {
22761 if (self.table.options.selectableRangeMode === "click
") {
22762 element.addEventListener("click
", function (e) {
22764 self.table._clearSelection();
22765 self.lastClickedRow = self.lastClickedRow || row;
22767 var lastClickedRowIdx = self.table.rowManager.getDisplayRowIndex(self.lastClickedRow);
22768 var rowIdx = self.table.rowManager.getDisplayRowIndex(row);
22770 var fromRowIdx = lastClickedRowIdx <= rowIdx ? lastClickedRowIdx : rowIdx;
22771 var toRowIdx = lastClickedRowIdx >= rowIdx ? lastClickedRowIdx : rowIdx;
22773 var rows = self.table.rowManager.getDisplayRows().slice(0);
22774 var toggledRows = rows.splice(fromRowIdx, toRowIdx - fromRowIdx + 1);
22776 if (e.ctrlKey || e.metaKey) {
22777 toggledRows.forEach(function (toggledRow) {
22778 if (toggledRow !== self.lastClickedRow) {
22780 if (self.table.options.selectable !== true && !self.isRowSelected(row)) {
22781 if (self.selectedRows.length < self.table.options.selectable) {
22782 self.toggleRow(toggledRow);
22785 self.toggleRow(toggledRow);
22789 self.lastClickedRow = row;
22791 self.deselectRows();
22793 if (self.table.options.selectable !== true) {
22794 if (toggledRows.length > self.table.options.selectable) {
22795 toggledRows = toggledRows.slice(0, self.table.options.selectable);
22799 self.selectRows(toggledRows);
22801 self.table._clearSelection();
22802 } else if (e.ctrlKey || e.metaKey) {
22803 self.toggleRow(row);
22804 self.lastClickedRow = row;
22806 self.deselectRows();
22807 self.selectRows(row);
22808 self.lastClickedRow = row;
22812 element.addEventListener("click
", function (e) {
22813 if (!self.table.modExists("edit
") || !self.table.modules.edit.getCurrentCell()) {
22814 self.table._clearSelection();
22817 if (!self.selecting) {
22818 self.toggleRow(row);
22822 element.addEventListener("mousedown
", function (e) {
22824 self.table._clearSelection();
22826 self.selecting = true;
22828 self.selectPrev = [];
22830 document.body.addEventListener("mouseup
", endSelect);
22831 document.body.addEventListener("keyup
", endSelect);
22833 self.toggleRow(row);
22839 element.addEventListener("mouseenter
", function (e) {
22840 if (self.selecting) {
22841 self.table._clearSelection();
22842 self.toggleRow(row);
22844 if (self.selectPrev[1] == row) {
22845 self.toggleRow(self.selectPrev[0]);
22850 element.addEventListener("mouseout
", function (e) {
22851 if (self.selecting) {
22852 self.table._clearSelection();
22853 self.selectPrev.unshift(row);
22859 element.classList.add("tabulator-unselectable
");
22860 element.classList.remove("tabulator-selectable
");
22864 //toggle row selection
22865 SelectRow.prototype.toggleRow = function (row) {
22866 if (this.table.options.selectableCheck.call(this.table, row.getComponent())) {
22867 if (row.modules.select && row.modules.select.selected) {
22868 this._deselectRow(row);
22870 this._selectRow(row);
22875 //select a number of rows
22876 SelectRow.prototype.selectRows = function (rows) {
22877 var _this65 = this;
22881 switch (typeof rows === 'undefined' ? 'undefined' : _typeof(rows)) {
22883 this.table.rowManager.rows.forEach(function (row) {
22884 _this65._selectRow(row, true, true);
22887 this._rowSelectionChanged();
22892 rowMatch = this.table.rowManager.findRow(rows);
22895 this._selectRow(rowMatch, true, true);
22897 this.table.rowManager.getRows(rows).forEach(function (row) {
22898 _this65._selectRow(row, true, true);
22902 this._rowSelectionChanged();
22906 if (Array.isArray(rows)) {
22907 rows.forEach(function (row) {
22908 _this65._selectRow(row, true, true);
22911 this._rowSelectionChanged();
22913 this._selectRow(rows, false, true);
22919 //select an individual row
22920 SelectRow.prototype._selectRow = function (rowInfo, silent, force) {
22923 //handle max row count
22924 if (!isNaN(this.table.options.selectable) && this.table.options.selectable !== true && !force) {
22925 if (this.selectedRows.length >= this.table.options.selectable) {
22926 if (this.table.options.selectableRollingSelection) {
22927 this._deselectRow(this.selectedRows[0]);
22934 var row = this.table.rowManager.findRow(rowInfo);
22937 if (this.selectedRows.indexOf(row) == -1) {
22938 if (!row.modules.select) {
22939 row.modules.select = {};
22942 row.modules.select.selected = true;
22943 if (row.modules.select.checkboxEl) {
22944 row.modules.select.checkboxEl.checked = true;
22946 row.getElement().classList.add("tabulator-selected
");
22948 this.selectedRows.push(row);
22951 this.table.options.rowSelected.call(this.table, row.getComponent());
22952 this._rowSelectionChanged();
22957 console.warn("Selection Error - No such row found, ignoring selection:
" + rowInfo);
22962 SelectRow.prototype.isRowSelected = function (row) {
22963 return this.selectedRows.indexOf(row) !== -1;
22966 //deselect a number of rows
22967 SelectRow.prototype.deselectRows = function (rows) {
22971 if (typeof rows == "undefined
") {
22973 rowCount = self.selectedRows.length;
22975 for (var i = 0; i < rowCount; i++) {
22976 self._deselectRow(self.selectedRows[0], true);
22979 self._rowSelectionChanged();
22981 if (Array.isArray(rows)) {
22982 rows.forEach(function (row) {
22983 self._deselectRow(row, true);
22986 self._rowSelectionChanged();
22988 self._deselectRow(rows);
22993 //deselect an individual row
22994 SelectRow.prototype._deselectRow = function (rowInfo, silent) {
22996 row = self.table.rowManager.findRow(rowInfo),
23000 index = self.selectedRows.findIndex(function (selectedRow) {
23001 return selectedRow == row;
23006 if (!row.modules.select) {
23007 row.modules.select = {};
23010 row.modules.select.selected = false;
23011 if (row.modules.select.checkboxEl) {
23012 row.modules.select.checkboxEl.checked = false;
23014 row.getElement().classList.remove("tabulator-selected
");
23015 self.selectedRows.splice(index, 1);
23018 self.table.options.rowDeselected.call(this.table, row.getComponent());
23019 self._rowSelectionChanged();
23024 console.warn("Deselection Error - No such row found, ignoring selection:
" + rowInfo);
23029 SelectRow.prototype.getSelectedData = function () {
23032 this.selectedRows.forEach(function (row) {
23033 data.push(row.getData());
23039 SelectRow.prototype.getSelectedRows = function () {
23043 this.selectedRows.forEach(function (row) {
23044 rows.push(row.getComponent());
23050 SelectRow.prototype._rowSelectionChanged = function () {
23051 if (this.headerCheckboxElement) {
23052 if (this.selectedRows.length === 0) {
23053 this.headerCheckboxElement.checked = false;
23054 this.headerCheckboxElement.indeterminate = false;
23055 } else if (this.table.rowManager.rows.length === this.selectedRows.length) {
23056 this.headerCheckboxElement.checked = true;
23057 this.headerCheckboxElement.indeterminate = false;
23059 this.headerCheckboxElement.indeterminate = true;
23060 this.headerCheckboxElement.checked = false;
23064 this.table.options.rowSelectionChanged.call(this.table, this.getSelectedData(), this.getSelectedRows());
23067 SelectRow.prototype.registerRowSelectCheckbox = function (row, element) {
23068 if (!row._row.modules.select) {
23069 row._row.modules.select = {};
23072 row._row.modules.select.checkboxEl = element;
23075 SelectRow.prototype.registerHeaderSelectCheckbox = function (element) {
23076 this.headerCheckboxElement = element;
23079 Tabulator.prototype.registerModule("selectRow
", SelectRow);
23081 var Sort = function Sort(table) {
23082 this.table = table; //hold Tabulator object
23083 this.sortList = []; //holder current sort
23084 this.changed = false; //has the sort changed since last render
23087 //initialize column header for sorting
23088 Sort.prototype.initializeColumn = function (column, content) {
23094 switch (_typeof(column.definition.sorter)) {
23096 if (self.sorters[column.definition.sorter]) {
23097 sorter = self.sorters[column.definition.sorter];
23099 console.warn("Sort Error - No such sorter found:
", column.definition.sorter);
23104 sorter = column.definition.sorter;
23108 column.modules.sort = {
23109 sorter: sorter, dir: "none
",
23110 params: column.definition.sorterParams || {},
23111 startingDir: column.definition.headerSortStartingDir || "asc
",
23112 tristate: typeof column.definition.headerSortTristate !== "undefined
" ? column.definition.headerSortTristate : this.table.options.headerSortTristate
23115 if (typeof column.definition.headerSort === "undefined
" ? this.table.options.headerSort !== false : column.definition.headerSort !== false) {
23117 colEl = column.getElement();
23119 colEl.classList.add("tabulator-sortable
");
23121 arrowEl = document.createElement("div
");
23122 arrowEl.classList.add("tabulator-arrow
");
23123 //create sorter arrow
23124 content.appendChild(arrowEl);
23127 colEl.addEventListener("click
", function (e) {
23132 if (column.modules.sort) {
23133 if (column.modules.sort.tristate) {
23134 if (column.modules.sort.dir == "none
") {
23135 dir = column.modules.sort.startingDir;
23137 if (column.modules.sort.dir == column.modules.sort.startingDir) {
23138 dir = column.modules.sort.dir == "asc
" ? "desc
" : "asc
";
23144 switch (column.modules.sort.dir) {
23154 dir = column.modules.sort.startingDir;
23158 if (self.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {
23159 sorters = self.getSort();
23161 match = sorters.findIndex(function (sorter) {
23162 return sorter.field === column.getField();
23166 sorters[match].dir = dir;
23168 if (match != sorters.length - 1) {
23169 match = sorters.splice(match, 1)[0];
23170 if (dir != "none
") {
23171 sorters.push(match);
23175 if (dir != "none
") {
23176 sorters.push({ column: column, dir: dir });
23180 //add to existing sort
23181 self.setSort(sorters);
23183 if (dir == "none
") {
23186 //sort by column only
23187 self.setSort(column, dir);
23191 self.table.rowManager.sorterRefresh(!self.sortList.length);
23197 //check if the sorters have changed since last use
23198 Sort.prototype.hasChanged = function () {
23199 var changed = this.changed;
23200 this.changed = false;
23204 //return current sorters
23205 Sort.prototype.getSort = function () {
23209 self.sortList.forEach(function (item) {
23211 sorters.push({ column: item.column.getComponent(), field: item.column.getField(), dir: item.dir });
23218 //change sort list and trigger sort
23219 Sort.prototype.setSort = function (sortList, dir) {
23223 if (!Array.isArray(sortList)) {
23224 sortList = [{ column: sortList, dir: dir }];
23227 sortList.forEach(function (item) {
23230 column = self.table.columnManager.findColumn(item.column);
23233 item.column = column;
23234 newSortList.push(item);
23235 self.changed = true;
23237 console.warn("Sort Warning - Sort field does not exist and is being ignored:
", item.column);
23241 self.sortList = newSortList;
23243 if (this.table.options.persistence && this.table.modExists("persistence
", true) && this.table.modules.persistence.config.sort) {
23244 this.table.modules.persistence.save("sort
");
23249 Sort.prototype.clear = function () {
23253 //find appropriate sorter for column
23254 Sort.prototype.findSorter = function (column) {
23255 var row = this.table.rowManager.activeRows[0],
23261 row = row.getData();
23262 field = column.getField();
23266 value = column.getFieldValue(row);
23268 switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
23274 sorter = "boolean";
23278 if (!isNaN(value) && value !== "") {
23281 if (value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)) {
23282 sorter = "alphanum
";
23290 return this.sorters[sorter];
23293 //work through sort list sorting data
23294 Sort.prototype.sort = function (data) {
23299 sortList = this.table.options.sortOrderReverse ? self.sortList.slice().reverse() : self.sortList;
23301 if (self.table.options.dataSorting) {
23302 self.table.options.dataSorting.call(self.table, self.getSort());
23305 self.clearColumnHeaders();
23307 if (!self.table.options.ajaxSorting) {
23309 sortList.forEach(function (item, i) {
23311 if (item.column && item.column.modules.sort) {
23313 //if no sorter has been defined, take a guess
23314 if (!item.column.modules.sort.sorter) {
23315 item.column.modules.sort.sorter = self.findSorter(item.column);
23318 self._sortItem(data, item.column, item.dir, sortList, i);
23321 self.setColumnHeader(item.column, item.dir);
23324 sortList.forEach(function (item, i) {
23325 self.setColumnHeader(item.column, item.dir);
23329 if (self.table.options.dataSorted) {
23330 self.table.options.dataSorted.call(self.table, self.getSort(), self.table.rowManager.getComponents("active
"));
23334 //clear sort arrows on columns
23335 Sort.prototype.clearColumnHeaders = function () {
23336 this.table.columnManager.getRealColumns().forEach(function (column) {
23337 if (column.modules.sort) {
23338 column.modules.sort.dir = "none
";
23339 column.getElement().setAttribute("aria-sort
", "none
");
23344 //set the column header sort direction
23345 Sort.prototype.setColumnHeader = function (column, dir) {
23346 column.modules.sort.dir = dir;
23347 column.getElement().setAttribute("aria-sort
", dir);
23350 //sort each item in sort list
23351 Sort.prototype._sortItem = function (data, column, dir, sortList, i) {
23354 var params = typeof column.modules.sort.params === "function" ? column.modules.sort.params(column.getComponent(), dir) : column.modules.sort.params;
23356 data.sort(function (a, b) {
23358 var result = self._sortRow(a, b, column, dir, params);
23360 //if results match recurse through previous searchs to be sure
23361 if (result === 0 && i) {
23362 for (var j = i - 1; j >= 0; j--) {
23363 result = self._sortRow(a, b, sortList[j].column, sortList[j].dir, params);
23365 if (result !== 0) {
23375 //process individual rows for a sort function on active data
23376 Sort.prototype._sortRow = function (a, b, column, dir, params) {
23377 var el1Comp, el2Comp, colComp;
23379 //switch elements depending on search direction
23380 var el1 = dir == "asc
" ? a : b;
23381 var el2 = dir == "asc
" ? b : a;
23383 a = column.getFieldValue(el1.getData());
23384 b = column.getFieldValue(el2.getData());
23386 a = typeof a !== "undefined
" ? a : "";
23387 b = typeof b !== "undefined
" ? b : "";
23389 el1Comp = el1.getComponent();
23390 el2Comp = el2.getComponent();
23392 return column.modules.sort.sorter.call(this, a, b, el1Comp, el2Comp, column.getComponent(), dir, params);
23395 //default data sorters
23396 Sort.prototype.sorters = {
23399 number: function number(a, b, aRow, bRow, column, dir, params) {
23400 var alignEmptyValues = params.alignEmptyValues;
23401 var decimal = params.decimalSeparator || ".
";
23402 var thousand = params.thousandSeparator || ",
";
23403 var emptyAlign = 0;
23405 a = parseFloat(String(a).split(thousand).join("").split(decimal).join(".
"));
23406 b = parseFloat(String(b).split(thousand).join("").split(decimal).join(".
"));
23408 //handle non numeric values
23410 emptyAlign = isNaN(b) ? 0 : -1;
23411 } else if (isNaN(b)) {
23414 //compare valid values
23418 //fix empty values in position
23419 if (alignEmptyValues === "top
" && dir === "desc
" || alignEmptyValues === "bottom
" && dir === "asc
") {
23427 string: function string(a, b, aRow, bRow, column, dir, params) {
23428 var alignEmptyValues = params.alignEmptyValues;
23429 var emptyAlign = 0;
23432 //handle empty values
23434 emptyAlign = !b ? 0 : -1;
23438 //compare valid values
23439 switch (_typeof(params.locale)) {
23441 if (params.locale) {
23442 locale = this.table.modules.localize.getLocale();
23446 locale = params.locale;
23450 return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);
23453 //fix empty values in position
23454 if (alignEmptyValues === "top
" && dir === "desc
" || alignEmptyValues === "bottom
" && dir === "asc
") {
23462 date: function date(a, b, aRow, bRow, column, dir, params) {
23463 if (!params.format) {
23464 params.format = "DD/MM/YYYY
";
23467 return this.sorters.datetime.call(this, a, b, aRow, bRow, column, dir, params);
23470 //sort hh:mm formatted times
23471 time: function time(a, b, aRow, bRow, column, dir, params) {
23472 if (!params.format) {
23473 params.format = "hh:mm
";
23476 return this.sorters.datetime.call(this, a, b, aRow, bRow, column, dir, params);
23480 datetime: function datetime(a, b, aRow, bRow, column, dir, params) {
23481 var format = params.format || "DD/MM/YYYY hh:mm:ss
",
23482 alignEmptyValues = params.alignEmptyValues,
23485 if (typeof moment != "undefined
") {
23486 a = moment(a, format);
23487 b = moment(b, format);
23489 if (!a.isValid()) {
23490 emptyAlign = !b.isValid() ? 0 : -1;
23491 } else if (!b.isValid()) {
23494 //compare valid values
23498 //fix empty values in position
23499 if (alignEmptyValues === "top
" && dir === "desc
" || alignEmptyValues === "bottom
" && dir === "asc
") {
23505 console.error("Sort Error -
'datetime' sorter is dependant on moment.js
");
23510 boolean: function boolean(a, b, aRow, bRow, column, dir, params) {
23511 var el1 = a === true || a === "true" || a === "True
" || a === 1 ? 1 : 0;
23512 var el2 = b === true || b === "true" || b === "True
" || b === 1 ? 1 : 0;
23517 //sort if element contains any data
23518 array: function array(a, b, aRow, bRow, column, dir, params) {
23521 var type = params.type || "length
";
23522 var alignEmptyValues = params.alignEmptyValues;
23523 var emptyAlign = 0;
23525 function calc(value) {
23529 return value.length;
23533 return value.reduce(function (c, d) {
23539 return Math.max.apply(null, value);
23543 return Math.min.apply(null, value);
23547 return value.reduce(function (c, d) {
23554 //handle non array values
23555 if (!Array.isArray(a)) {
23556 alignEmptyValues = !Array.isArray(b) ? 0 : -1;
23557 } else if (!Array.isArray(b)) {
23558 alignEmptyValues = 1;
23561 //compare valid values
23562 el1 = a ? calc(a) : 0;
23563 el2 = b ? calc(b) : 0;
23568 //fix empty values in position
23569 if (alignEmptyValues === "top
" && dir === "desc
" || alignEmptyValues === "bottom
" && dir === "asc
") {
23576 //sort if element contains any data
23577 exists: function exists(a, b, aRow, bRow, column, dir, params) {
23578 var el1 = typeof a == "undefined
" ? 0 : 1;
23579 var el2 = typeof b == "undefined
" ? 0 : 1;
23584 //sort alpha numeric strings
23585 alphanum: function alphanum(as, bs, aRow, bRow, column, dir, params) {
23592 rx = /(\d+)|(\D+)/g,
23594 var alignEmptyValues = params.alignEmptyValues;
23595 var emptyAlign = 0;
23597 //handle empty values
23598 if (!as && as !== 0) {
23599 emptyAlign = !bs && bs !== 0 ? 0 : -1;
23600 } else if (!bs && bs !== 0) {
23604 if (isFinite(as) && isFinite(bs)) return as - bs;
23605 a = String(as).toLowerCase();
23606 b = String(bs).toLowerCase();
23607 if (a === b) return 0;
23608 if (!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;
23611 L = a.length > b.length ? b.length : a.length;
23616 if (isFinite(a1) && isFinite(b1)) {
23617 if (a1.charAt(0) === "0
") a1 = ".
" + a1;
23618 if (b1.charAt(0) === "0
") b1 = ".
" + b1;
23620 } else return a1 > b1 ? 1 : -1;
23624 return a.length > b.length;
23627 //fix empty values in position
23628 if (alignEmptyValues === "top
" && dir === "desc
" || alignEmptyValues === "bottom
" && dir === "asc
") {
23636 Tabulator.prototype.registerModule("sort
", Sort);
23638 var Validate = function Validate(table) {
23639 this.table = table;
23643 Validate.prototype.initializeColumn = function (column) {
23648 if (column.definition.validator) {
23650 if (Array.isArray(column.definition.validator)) {
23651 column.definition.validator.forEach(function (item) {
23652 validator = self._extractValidator(item);
23655 config.push(validator);
23659 validator = this._extractValidator(column.definition.validator);
23662 config.push(validator);
23666 column.modules.validate = config.length ? config : false;
23670 Validate.prototype._extractValidator = function (value) {
23671 var type, params, pos;
23673 switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
23675 pos = value.indexOf(':');
23678 type = value.substring(0, pos);
23679 params = value.substring(pos + 1);
23684 return this._buildValidator(type, params);
23688 return this._buildValidator(value);
23692 return this._buildValidator(value.type, value.parameters);
23697 Validate.prototype._buildValidator = function (type, params) {
23699 var func = typeof type == "function" ? type : this.validators[type];
23702 console.warn("Validator Setup Error - No matching validator found:
", type);
23706 type: typeof type == "function" ? "function" : type,
23713 Validate.prototype.validate = function (validators, cell, value) {
23718 validators.forEach(function (item) {
23719 if (!item.func.call(self, cell, value, item.params)) {
23722 parameters: item.params
23728 return valid.length ? valid : true;
23731 Validate.prototype.validators = {
23734 integer: function integer(cell, value, parameters) {
23735 if (value === "" || value === null || typeof value === "undefined
") {
23738 value = Number(value);
23739 return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
23743 float: function float(cell, value, parameters) {
23744 if (value === "" || value === null || typeof value === "undefined
") {
23747 value = Number(value);
23748 return typeof value === 'number' && isFinite(value) && value % 1 !== 0;
23752 numeric: function numeric(cell, value, parameters) {
23753 if (value === "" || value === null || typeof value === "undefined
") {
23756 return !isNaN(value);
23760 string: function string(cell, value, parameters) {
23761 if (value === "" || value === null || typeof value === "undefined
") {
23764 return isNaN(value);
23768 max: function max(cell, value, parameters) {
23769 if (value === "" || value === null || typeof value === "undefined
") {
23772 return parseFloat(value) <= parameters;
23776 min: function min(cell, value, parameters) {
23777 if (value === "" || value === null || typeof value === "undefined
") {
23780 return parseFloat(value) >= parameters;
23783 //minimum string length
23784 minLength: function minLength(cell, value, parameters) {
23785 if (value === "" || value === null || typeof value === "undefined
") {
23788 return String(value).length >= parameters;
23791 //maximum string length
23792 maxLength: function maxLength(cell, value, parameters) {
23793 if (value === "" || value === null || typeof value === "undefined
") {
23796 return String(value).length <= parameters;
23799 //in provided value list
23800 in: function _in(cell, value, parameters) {
23801 if (value === "" || value === null || typeof value === "undefined
") {
23804 if (typeof parameters == "string") {
23805 parameters = parameters.split("|
");
23808 return value === "" || parameters.indexOf(value) > -1;
23811 //must match provided regex
23812 regex: function regex(cell, value, parameters) {
23813 if (value === "" || value === null || typeof value === "undefined
") {
23816 var reg = new RegExp(parameters);
23818 return reg.test(value);
23821 //value must be unique in this column
23822 unique: function unique(cell, value, parameters) {
23823 if (value === "" || value === null || typeof value === "undefined
") {
23828 var cellData = cell.getData();
23829 var column = cell.getColumn()._getSelf();
23831 this.table.rowManager.rows.forEach(function (row) {
23832 var data = row.getData();
23834 if (data !== cellData) {
23835 if (value == column.getFieldValue(data)) {
23844 //must have a value
23845 required: function required(cell, value, parameters) {
23846 return value !== "" && value !== null && typeof value !== "undefined
";
23850 Tabulator.prototype.registerModule("validate
", Validate);