7 var _typeof = typeof Symbol ===
"function" && typeof Symbol.iterator ===
"symbol" ?
function (obj) {
return typeof obj; } :
function (obj) {
return obj && typeof Symbol ===
"function" && obj.constructor === Symbol && obj !== Symbol.prototype ?
"symbol" : typeof obj; };
9 if (!Array.prototype.findIndex) {
11 Object.defineProperty(Array.prototype,
'findIndex', {
13 value:
function value(predicate) {
19 throw new TypeError(
'"this" is null or not defined');
26 var len = o.length >>> 0;
30 if (typeof predicate !==
'function') {
32 throw new TypeError(
'predicate must be a function');
37 var thisArg = arguments[1];
57 if (predicate.call(thisArg, kValue, k, o)) {
77 if (!Array.prototype.find) {
79 Object.defineProperty(Array.prototype,
'find', {
81 value:
function value(predicate) {
87 throw new TypeError(
'"this" is null or not defined');
94 var len = o.length >>> 0;
98 if (typeof predicate !==
'function') {
100 throw new TypeError(
'predicate must be a function');
105 var thisArg = arguments[1];
125 if (predicate.call(thisArg, kValue, k, o)) {
143 var ColumnManager =
function ColumnManager(table) {
147 this.blockHozScrollEvent =
false;
149 this.headersElement = this.createHeadersElement();
151 this.element = this.createHeaderElement();
153 this.rowManager = null;
157 this.columnsByIndex = [];
159 this.columnsByField = {};
163 this.element.insertBefore(this.headersElement, this.element.firstChild);
169 ColumnManager.prototype.createHeadersElement =
function () {
171 var el = document.createElement(
"div");
173 el.classList.add(
"tabulator-headers");
178 ColumnManager.prototype.createHeaderElement =
function () {
180 var el = document.createElement(
"div");
182 el.classList.add(
"tabulator-header");
184 if (!this.table.options.headerVisible) {
186 el.classList.add(
"tabulator-header-hidden");
192 ColumnManager.prototype.initialize =
function () {
211 ColumnManager.prototype.setRowManager =
function (manager) {
213 this.rowManager = manager;
218 ColumnManager.prototype.getElement =
function () {
225 ColumnManager.prototype.getHeadersElement =
function () {
227 return this.headersElement;
241 ColumnManager.prototype.scrollHorizontal =
function (left) {
244 scrollWidth = this.element.scrollWidth - this.table.element.clientWidth;
248 this.element.scrollLeft = left;
252 if (left > scrollWidth) {
254 hozAdjust = left - scrollWidth;
256 this.element.style.marginLeft = -hozAdjust +
"px";
259 this.element.style.marginLeft = 0;
267 this.scrollLeft = left;
269 if (this.table.modExists(
"frozenColumns")) {
271 this.table.modules.frozenColumns.scrollHorizontal();
278 ColumnManager.prototype.generateColumnsFromRowData =
function (data) {
284 if (data && data.length) {
288 for (var key in row) {
298 var value = row[key];
300 switch (typeof value ===
'undefined' ?
'undefined' : _typeof(value)) {
316 if (Array.isArray(value)) {
328 if (!isNaN(value) && value !==
"") {
333 if (value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)) {
351 this.table.options.columns = cols;
353 this.setColumns(this.table.options.columns);
357 ColumnManager.prototype.setColumns =
function (cols, row) {
361 while (
self.headersElement.firstChild) {
362 self.headersElement.removeChild(
self.headersElement.firstChild);
365 self.columnsByIndex = [];
367 self.columnsByField = {};
371 if (
self.table.modExists(
"frozenColumns")) {
373 self.table.modules.frozenColumns.reset();
376 cols.forEach(
function (def, i) {
378 self._addColumn(def);
381 self._reIndexColumns();
383 if (
self.table.options.responsiveLayout &&
self.table.modExists(
"responsiveLayout",
true)) {
385 self.table.modules.responsiveLayout.initialize();
391 ColumnManager.prototype._addColumn =
function (definition, before, nextToColumn) {
393 var column =
new Column(definition,
this),
394 colEl = column.getElement(),
395 index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;
397 if (nextToColumn && index > -1) {
399 var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn());
401 var nextEl = nextToColumn.getElement();
405 this.columns.splice(parentIndex, 0, column);
407 nextEl.parentNode.insertBefore(colEl, nextEl);
410 this.columns.splice(parentIndex + 1, 0, column);
412 nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);
418 this.columns.unshift(column);
420 this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild);
423 this.columns.push(column);
425 this.headersElement.appendChild(column.getElement());
428 column.columnRendered();
434 ColumnManager.prototype.registerColumnField =
function (col) {
436 if (col.definition.field) {
438 this.columnsByField[col.definition.field] = col;
442 ColumnManager.prototype.registerColumnPosition =
function (col) {
444 this.columnsByIndex.push(col);
447 ColumnManager.prototype._reIndexColumns =
function () {
449 this.columnsByIndex = [];
451 this.columns.forEach(
function (column) {
453 column.reRegisterPosition();
459 ColumnManager.prototype._verticalAlignHeaders =
function () {
464 self.columns.forEach(
function (column) {
468 column.clearVerticalAlign();
470 height = column.getHeight();
472 if (height > minHeight) {
478 self.columns.forEach(
function (column) {
480 column.verticalAlign(
self.table.options.columnHeaderVertAlign, minHeight);
483 self.rowManager.adjustTableSize();
489 ColumnManager.prototype.findColumn =
function (subject) {
493 if ((typeof subject ===
'undefined' ?
'undefined' : _typeof(subject)) ==
"object") {
495 if (subject instanceof Column) {
500 }
else if (subject instanceof ColumnComponent) {
504 return subject._getSelf() ||
false;
505 }
else if (typeof HTMLElement !==
"undefined" && subject instanceof HTMLElement) {
509 var match =
self.columns.find(
function (column) {
511 return column.element === subject;
514 return match ||
false;
520 return this.columnsByField[subject] ||
false;
529 ColumnManager.prototype.getColumnByField =
function (field) {
531 return this.columnsByField[field];
534 ColumnManager.prototype.getColumnsByFieldRoot =
function (root) {
539 Object.keys(this.columnsByField).forEach(
function (field) {
541 var fieldRoot = field.split(
".")[0];
543 if (fieldRoot === root) {
545 matches.push(_this.columnsByField[field]);
552 ColumnManager.prototype.getColumnByIndex =
function (index) {
554 return this.columnsByIndex[index];
557 ColumnManager.prototype.getFirstVisibileColumn =
function (index) {
559 var index = this.columnsByIndex.findIndex(
function (col) {
564 return index > -1 ? this.columnsByIndex[index] :
false;
567 ColumnManager.prototype.getColumns =
function () {
572 ColumnManager.prototype.findColumnIndex =
function (column) {
574 return this.columnsByIndex.findIndex(
function (col) {
576 return column === col;
582 ColumnManager.prototype.getRealColumns =
function () {
584 return this.columnsByIndex;
589 ColumnManager.prototype.traverse =
function (callback) {
593 self.columnsByIndex.forEach(
function (column, i) {
601 ColumnManager.prototype.getDefinitions =
function (active) {
606 self.columnsByIndex.forEach(
function (column) {
608 if (!active || active && column.visible) {
610 output.push(column.getDefinition());
619 ColumnManager.prototype.getDefinitionTree =
function () {
624 self.columns.forEach(
function (column) {
626 output.push(column.getDefinition(
true));
632 ColumnManager.prototype.getComponents =
function (structured) {
636 columns = structured ?
self.columns :
self.columnsByIndex;
638 columns.forEach(
function (column) {
640 output.push(column.getComponent());
646 ColumnManager.prototype.getWidth =
function () {
650 this.columnsByIndex.forEach(
function (column) {
652 if (column.visible) {
654 width += column.getWidth();
661 ColumnManager.prototype.moveColumn =
function (from, to, after) {
663 this.moveColumnActual(from, to, after);
665 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
667 this.table.modules.responsiveLayout.initialize();
670 if (this.table.modExists(
"columnCalcs")) {
672 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
675 to.element.parentNode.insertBefore(from.element, to.element);
679 to.element.parentNode.insertBefore(to.element, from.element);
682 this._verticalAlignHeaders();
684 this.table.rowManager.reinitialize();
687 ColumnManager.prototype.moveColumnActual =
function (from, to, after) {
689 this._moveColumnInArray(this.columns, from, to, after);
691 this._moveColumnInArray(this.columnsByIndex, from, to, after,
true);
693 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
695 this.table.modules.responsiveLayout.initialize();
698 if (this.table.options.columnMoved) {
700 this.table.options.columnMoved.call(this.table, from.getComponent(), this.table.columnManager.getComponents());
703 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
705 this.table.modules.persistence.save(
"columns");
709 ColumnManager.prototype._moveColumnInArray =
function (columns, from, to, after, updateRows) {
711 var fromIndex = columns.indexOf(from),
714 if (fromIndex > -1) {
716 columns.splice(fromIndex, 1);
718 toIndex = columns.indexOf(to);
724 toIndex = toIndex + 1;
731 columns.splice(toIndex, 0, from);
735 this.table.rowManager.rows.forEach(
function (row) {
737 if (row.cells.length) {
739 var cell = row.cells.splice(fromIndex, 1)[0];
741 row.cells.splice(toIndex, 0, cell);
748 ColumnManager.prototype.scrollToColumn =
function (column, position, ifVisible) {
754 colEl = column.getElement();
756 return new Promise(
function (resolve, reject) {
758 if (typeof position ===
"undefined") {
760 position = _this2.table.options.scrollToColumnPosition;
763 if (typeof ifVisible ===
"undefined") {
765 ifVisible = _this2.table.options.scrollToColumnIfVisible;
768 if (column.visible) {
778 adjust = -_this2.element.clientWidth / 2;
784 adjust = colEl.clientWidth - _this2.headersElement.clientWidth;
794 offset = colEl.offsetLeft;
796 if (offset > 0 && offset + colEl.offsetWidth < _this2.element.clientWidth) {
804 left = colEl.offsetLeft + _this2.element.scrollLeft + adjust;
806 left = Math.max(Math.min(left, _this2.table.rowManager.element.scrollWidth - _this2.table.rowManager.element.clientWidth), 0);
808 _this2.table.rowManager.scrollHorizontal(left);
810 _this2.scrollHorizontal(left);
815 console.warn(
"Scroll Error - Column not visible");
817 reject(
"Scroll Error - Column not visible");
825 ColumnManager.prototype.generateCells =
function (row) {
831 self.columnsByIndex.forEach(
function (column) {
833 cells.push(column.generateCell(row));
842 ColumnManager.prototype.getFlexBaseWidth =
function () {
845 totalWidth =
self.table.element.clientWidth,
852 if (
self.rowManager.element.scrollHeight >
self.rowManager.element.clientHeight) {
854 totalWidth -=
self.rowManager.element.offsetWidth -
self.rowManager.element.clientWidth;
857 this.columnsByIndex.forEach(
function (column) {
859 var width, minWidth, colWidth;
861 if (column.visible) {
863 width = column.definition.width || 0;
865 minWidth = typeof column.minWidth ==
"undefined" ?
self.table.options.columnMinWidth : parseInt(column.minWidth);
867 if (typeof width ==
"string") {
869 if (width.indexOf(
"%") > -1) {
871 colWidth = totalWidth / 100 * parseInt(width);
874 colWidth = parseInt(width);
881 fixedWidth += colWidth > minWidth ? colWidth : minWidth;
888 ColumnManager.prototype.addColumn =
function (definition, before, nextToColumn) {
891 return new Promise(
function (resolve, reject) {
893 var column = _this3._addColumn(definition, before, nextToColumn);
895 _this3._reIndexColumns();
897 if (_this3.table.options.responsiveLayout && _this3.table.modExists(
"responsiveLayout",
true)) {
899 _this3.table.modules.responsiveLayout.initialize();
902 if (_this3.table.modExists(
"columnCalcs")) {
904 _this3.table.modules.columnCalcs.recalc(_this3.table.rowManager.activeRows);
909 if (_this3.table.modules.layout.getMode() !=
"fitColumns") {
911 column.reinitializeWidth();
914 _this3._verticalAlignHeaders();
916 _this3.table.rowManager.reinitialize();
924 ColumnManager.prototype.deregisterColumn =
function (column) {
926 var field = column.getField(),
933 delete this.columnsByField[field];
938 index = this.columnsByIndex.indexOf(column);
942 this.columnsByIndex.splice(index, 1);
947 index = this.columns.indexOf(column);
951 this.columns.splice(index, 1);
954 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
956 this.table.modules.responsiveLayout.initialize();
964 ColumnManager.prototype.redraw =
function (force) {
968 if (Tabulator.prototype.helpers.elVisible(
this.element)) {
970 this._verticalAlignHeaders();
973 this.table.rowManager.resetScroll();
975 this.table.rowManager.reinitialize();
978 if ([
"fitColumns",
"fitDataStretch"].indexOf(this.table.modules.layout.getMode()) > -1) {
980 this.table.modules.layout.layout();
985 this.table.modules.layout.layout();
988 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
990 this.table.modules.responsiveLayout.update();
995 if (this.table.modExists(
"frozenColumns")) {
997 this.table.modules.frozenColumns.layout();
1000 if (this.table.modExists(
"columnCalcs")) {
1002 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
1007 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
1009 this.table.modules.persistence.save(
"columns");
1012 if (this.table.modExists(
"columnCalcs")) {
1014 this.table.modules.columnCalcs.redraw();
1018 this.table.footerManager.redraw();
1022 var ColumnComponent =
function ColumnComponent(column) {
1023 this._column = column;
1024 this.type =
"ColumnComponent";
1027 ColumnComponent.prototype.getElement =
function () {
1028 return this._column.getElement();
1031 ColumnComponent.prototype.getDefinition =
function () {
1032 return this._column.getDefinition();
1035 ColumnComponent.prototype.getField =
function () {
1036 return this._column.getField();
1039 ColumnComponent.prototype.getCells =
function () {
1042 this._column.cells.forEach(
function (cell) {
1043 cells.push(cell.getComponent());
1049 ColumnComponent.prototype.getVisibility =
function () {
1050 return this._column.visible;
1053 ColumnComponent.prototype.show =
function () {
1054 if (this._column.isGroup) {
1055 this._column.columns.forEach(
function (column) {
1059 this._column.show();
1063 ColumnComponent.prototype.hide =
function () {
1064 if (this._column.isGroup) {
1065 this._column.columns.forEach(
function (column) {
1069 this._column.hide();
1073 ColumnComponent.prototype.toggle =
function () {
1074 if (this._column.visible) {
1081 ColumnComponent.prototype.delete =
function () {
1082 return this._column.delete();
1085 ColumnComponent.prototype.getSubColumns =
function () {
1088 if (this._column.columns.length) {
1089 this._column.columns.forEach(
function (column) {
1090 output.push(column.getComponent());
1097 ColumnComponent.prototype.getParentColumn =
function () {
1098 return this._column.parent instanceof Column ? this._column.parent.getComponent() :
false;
1101 ColumnComponent.prototype._getSelf =
function () {
1102 return this._column;
1105 ColumnComponent.prototype.scrollTo =
function () {
1106 return this._column.table.columnManager.scrollToColumn(this._column);
1109 ColumnComponent.prototype.getTable =
function () {
1110 return this._column.table;
1113 ColumnComponent.prototype.headerFilterFocus =
function () {
1114 if (this._column.table.modExists(
"filter",
true)) {
1115 this._column.table.modules.filter.setHeaderFilterFocus(this._column);
1119 ColumnComponent.prototype.reloadHeaderFilter =
function () {
1120 if (this._column.table.modExists(
"filter",
true)) {
1121 this._column.table.modules.filter.reloadHeaderFilter(this._column);
1125 ColumnComponent.prototype.setHeaderFilterValue =
function (value) {
1126 if (this._column.table.modExists(
"filter",
true)) {
1127 this._column.table.modules.filter.setHeaderFilterValue(this._column, value);
1131 ColumnComponent.prototype.move =
function (to, after) {
1132 var toColumn = this._column.table.columnManager.findColumn(to);
1135 this._column.table.columnManager.moveColumn(this._column, toColumn, after);
1137 console.warn(
"Move Error - No matching column found:", toColumn);
1141 ColumnComponent.prototype.getNextColumn =
function () {
1142 var nextCol = this._column.nextColumn();
1144 return nextCol ? nextCol.getComponent() :
false;
1147 ColumnComponent.prototype.getPrevColumn =
function () {
1148 var prevCol = this._column.prevColumn();
1150 return prevCol ? prevCol.getComponent() :
false;
1153 ColumnComponent.prototype.updateDefinition =
function (updates) {
1154 return this._column.updateDefinition(updates);
1157 var Column =
function Column(def, parent) {
1160 this.table = parent.table;
1161 this.definition = def;
1162 this.parent = parent;
1163 this.type =
"column";
1166 this.element = this.createElement();
1167 this.contentElement =
false;
1168 this.groupElement = this.createGroupElement();
1169 this.isGroup =
false;
1170 this.tooltip =
false;
1175 this.fieldStructure =
"";
1176 this.getFieldValue =
"";
1177 this.setFieldValue =
"";
1179 this.titleFormatterRendered =
false;
1181 this.setField(this.definition.field);
1183 if (this.table.options.invalidOptionWarnings) {
1184 this.checkDefinition();
1191 cellDblClick:
false,
1196 cellMouseEnter:
false,
1197 cellMouseLeave:
false,
1198 cellMouseOver:
false,
1199 cellMouseOut:
false,
1200 cellMouseMove:
false
1204 this.widthStyled =
"";
1205 this.minWidth = null;
1206 this.minWidthStyled =
"";
1207 this.widthFixed =
false;
1209 this.visible =
true;
1211 this._mapDepricatedFunctionality();
1216 this.isGroup =
true;
1218 def.columns.forEach(
function (def, i) {
1219 var newCol =
new Column(def,
self);
1220 self.attachColumn(newCol);
1223 self.checkColumnVisibility();
1225 parent.registerColumnField(
this);
1228 if (def.rowHandle &&
this.table.options.movableRows !==
false &&
this.table.modExists(
"moveRow")) {
1229 this.table.modules.moveRow.setHandle(
true);
1232 this._buildHeader();
1234 this.bindModuleColumns();
1237 Column.prototype.createElement =
function () {
1238 var el = document.createElement(
"div");
1240 el.classList.add(
"tabulator-col");
1241 el.setAttribute(
"role",
"columnheader");
1242 el.setAttribute(
"aria-sort",
"none");
1247 Column.prototype.createGroupElement =
function () {
1248 var el = document.createElement(
"div");
1250 el.classList.add(
"tabulator-col-group-cols");
1255 Column.prototype.checkDefinition =
function () {
1258 Object.keys(this.definition).forEach(
function (key) {
1259 if (_this4.defaultOptionList.indexOf(key) === -1) {
1260 console.warn(
"Invalid column definition option in '" + (_this4.field || _this4.definition.title) +
"' column:", key);
1265 Column.prototype.setField =
function (field) {
1267 this.fieldStructure = field ? this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field] : [];
1268 this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;
1269 this.setFieldValue = this.fieldStructure.length > 1 ? this._setNesteData : this._setFlatData;
1273 Column.prototype.registerColumnPosition =
function (column) {
1274 this.parent.registerColumnPosition(column);
1278 Column.prototype.registerColumnField =
function (column) {
1279 this.parent.registerColumnField(column);
1283 Column.prototype.reRegisterPosition =
function () {
1285 this.columns.forEach(
function (column) {
1286 column.reRegisterPosition();
1289 this.registerColumnPosition(
this);
1293 Column.prototype._mapDepricatedFunctionality =
function () {
1294 if (typeof this.definition.hideInHtml !==
"undefined") {
1295 this.definition.htmlOutput = !this.definition.hideInHtml;
1296 console.warn(
"hideInHtml column definition property is deprecated, you should now use htmlOutput");
1300 Column.prototype.setTooltip =
function () {
1302 def =
self.definition;
1305 var tooltip = def.headerTooltip || def.tooltip ===
false ? def.headerTooltip :
self.table.options.tooltipsHeader;
1308 if (tooltip ===
true) {
1310 self.table.modules.localize.bind(
"columns|" + def.field, function (value) {
1311 self.element.setAttribute(
"title", value || def.title);
1314 self.element.setAttribute(
"title", def.title);
1317 if (typeof tooltip ==
"function") {
1318 tooltip = tooltip(
self.getComponent());
1320 if (tooltip ===
false) {
1325 self.element.setAttribute(
"title", tooltip);
1328 self.element.setAttribute(
"title",
"");
1333 Column.prototype._buildHeader =
function () {
1335 def =
self.definition;
1337 while (
self.element.firstChild) {
1338 self.element.removeChild(
self.element.firstChild);
1339 }
if (def.headerVertical) {
1340 self.element.classList.add(
"tabulator-col-vertical");
1342 if (def.headerVertical ===
"flip") {
1343 self.element.classList.add(
"tabulator-col-vertical-flip");
1347 self.contentElement =
self._bindEvents();
1349 self.contentElement =
self._buildColumnHeaderContent();
1351 self.element.appendChild(
self.contentElement);
1354 self._buildGroupHeader();
1356 self._buildColumnHeader();
1362 if (
self.table.options.resizableColumns &&
self.table.modExists(
"resizeColumns")) {
1363 self.table.modules.resizeColumns.initializeColumn(
"header",
self,
self.element);
1367 if (def.headerFilter &&
self.table.modExists(
"filter") &&
self.table.modExists(
"edit")) {
1368 if (typeof def.headerFilterPlaceholder !==
"undefined" && def.field) {
1369 self.table.modules.localize.setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder);
1372 self.table.modules.filter.initializeColumn(
self);
1376 if (
self.table.modExists(
"frozenColumns")) {
1377 self.table.modules.frozenColumns.initializeColumn(
self);
1381 if (
self.table.options.movableColumns && !
self.isGroup &&
self.table.modExists(
"moveColumn")) {
1382 self.table.modules.moveColumn.initializeColumn(
self);
1386 if ((def.topCalc || def.bottomCalc) &&
self.table.modExists(
"columnCalcs")) {
1387 self.table.modules.columnCalcs.initializeColumn(
self);
1391 if (
self.table.modExists(
"persistence") &&
self.table.modules.persistence.config.columns) {
1392 self.table.modules.persistence.initializeColumn(
self);
1396 self.element.addEventListener(
"mouseenter",
function (e) {
1401 Column.prototype._bindEvents =
function () {
1404 def =
self.definition,
1410 if (typeof def.headerClick ==
"function") {
1411 self.element.addEventListener(
"click",
function (e) {
1412 def.headerClick(e,
self.getComponent());
1416 if (typeof def.headerDblClick ==
"function") {
1417 self.element.addEventListener(
"dblclick",
function (e) {
1418 def.headerDblClick(e,
self.getComponent());
1422 if (typeof def.headerContext ==
"function") {
1423 self.element.addEventListener(
"contextmenu",
function (e) {
1424 def.headerContext(e,
self.getComponent());
1429 if (typeof def.headerTap ==
"function") {
1432 self.element.addEventListener(
"touchstart",
function (e) {
1434 }, { passive:
true });
1436 self.element.addEventListener(
"touchend",
function (e) {
1438 def.headerTap(e,
self.getComponent());
1445 if (typeof def.headerDblTap ==
"function") {
1448 self.element.addEventListener(
"touchend",
function (e) {
1451 clearTimeout(dblTap);
1454 def.headerDblTap(e,
self.getComponent());
1457 dblTap = setTimeout(
function () {
1458 clearTimeout(dblTap);
1465 if (typeof def.headerTapHold ==
"function") {
1468 self.element.addEventListener(
"touchstart",
function (e) {
1469 clearTimeout(tapHold);
1471 tapHold = setTimeout(
function () {
1472 clearTimeout(tapHold);
1475 def.headerTapHold(e,
self.getComponent());
1477 }, { passive:
true });
1479 self.element.addEventListener(
"touchend",
function (e) {
1480 clearTimeout(tapHold);
1486 if (typeof def.cellClick ==
"function") {
1487 self.cellEvents.cellClick = def.cellClick;
1490 if (typeof def.cellDblClick ==
"function") {
1491 self.cellEvents.cellDblClick = def.cellDblClick;
1494 if (typeof def.cellContext ==
"function") {
1495 self.cellEvents.cellContext = def.cellContext;
1499 if (typeof def.cellMouseEnter ==
"function") {
1500 self.cellEvents.cellMouseEnter = def.cellMouseEnter;
1503 if (typeof def.cellMouseLeave ==
"function") {
1504 self.cellEvents.cellMouseLeave = def.cellMouseLeave;
1507 if (typeof def.cellMouseOver ==
"function") {
1508 self.cellEvents.cellMouseOver = def.cellMouseOver;
1511 if (typeof def.cellMouseOut ==
"function") {
1512 self.cellEvents.cellMouseOut = def.cellMouseOut;
1515 if (typeof def.cellMouseMove ==
"function") {
1516 self.cellEvents.cellMouseMove = def.cellMouseMove;
1520 if (typeof def.cellTap ==
"function") {
1521 self.cellEvents.cellTap = def.cellTap;
1524 if (typeof def.cellDblTap ==
"function") {
1525 self.cellEvents.cellDblTap = def.cellDblTap;
1528 if (typeof def.cellTapHold ==
"function") {
1529 self.cellEvents.cellTapHold = def.cellTapHold;
1533 if (typeof def.cellEdited ==
"function") {
1534 self.cellEvents.cellEdited = def.cellEdited;
1537 if (typeof def.cellEditing ==
"function") {
1538 self.cellEvents.cellEditing = def.cellEditing;
1541 if (typeof def.cellEditCancelled ==
"function") {
1542 self.cellEvents.cellEditCancelled = def.cellEditCancelled;
1547 Column.prototype._buildColumnHeader =
function () {
1549 def =
self.definition,
1554 if (table.modExists(
"sort")) {
1555 table.modules.sort.initializeColumn(
self,
self.contentElement);
1559 if (table.modExists(
"format")) {
1560 table.modules.format.initializeColumn(
self);
1564 if (typeof def.editor !=
"undefined" && table.modExists(
"edit")) {
1565 table.modules.edit.initializeColumn(
self);
1569 if (typeof def.validator !=
"undefined" && table.modExists(
"validate")) {
1570 table.modules.validate.initializeColumn(
self);
1574 if (table.modExists(
"mutator")) {
1575 table.modules.mutator.initializeColumn(
self);
1579 if (table.modExists(
"accessor")) {
1580 table.modules.accessor.initializeColumn(
self);
1584 if (_typeof(table.options.responsiveLayout) && table.modExists(
"responsiveLayout")) {
1585 table.modules.responsiveLayout.initializeColumn(
self);
1589 if (typeof def.visible !=
"undefined") {
1599 var classeNames = def.cssClass.split(
" ");
1600 classeNames.forEach(
function (className) {
1601 self.element.classList.add(className);
1606 this.element.setAttribute(
"tabulator-field", def.field);
1610 self.setMinWidth(typeof def.minWidth ==
"undefined" ?
self.table.options.columnMinWidth : parseInt(def.minWidth));
1612 self.reinitializeWidth();
1615 self.tooltip =
self.definition.tooltip ||
self.definition.tooltip ===
false ?
self.definition.tooltip :
self.table.options.tooltips;
1618 self.hozAlign = typeof
self.definition.align ==
"undefined" ?
"" :
self.definition.align;
1621 Column.prototype._buildColumnHeaderContent =
function () {
1623 def =
self.definition,
1626 var contentElement = document.createElement(
"div");
1627 contentElement.classList.add(
"tabulator-col-content");
1629 contentElement.appendChild(
self._buildColumnHeaderTitle());
1631 return contentElement;
1635 Column.prototype._buildColumnHeaderTitle =
function () {
1637 def =
self.definition,
1641 var titleHolderElement = document.createElement(
"div");
1642 titleHolderElement.classList.add(
"tabulator-col-title");
1644 if (def.editableTitle) {
1645 var titleElement = document.createElement(
"input");
1646 titleElement.classList.add(
"tabulator-title-editor");
1648 titleElement.addEventListener(
"click",
function (e) {
1649 e.stopPropagation();
1650 titleElement.focus();
1653 titleElement.addEventListener(
"change",
function () {
1654 def.title = titleElement.value;
1655 table.options.columnTitleChanged.call(
self.table,
self.getComponent());
1658 titleHolderElement.appendChild(titleElement);
1661 table.modules.localize.bind(
"columns|" + def.field, function (text) {
1662 titleElement.value = text || def.title ||
" ";
1665 titleElement.value = def.title ||
" ";
1669 table.modules.localize.bind(
"columns|" + def.field, function (text) {
1670 self._formatColumnHeaderTitle(titleHolderElement, text || def.title ||
" ");
1673 self._formatColumnHeaderTitle(titleHolderElement, def.title ||
" ");
1677 return titleHolderElement;
1680 Column.prototype._formatColumnHeaderTitle =
function (el, title) {
1683 var formatter, contents, params, mockCell, onRendered;
1685 if (this.definition.titleFormatter &&
this.table.modExists(
"format")) {
1687 formatter = this.table.modules.format.getFormatter(this.definition.titleFormatter);
1689 onRendered =
function onRendered(callback) {
1690 _this5.titleFormatterRendered = callback;
1694 getValue:
function getValue() {
1697 getElement:
function getElement() {
1702 params = this.definition.titleFormatterParams || {};
1704 params = typeof params ===
"function" ? params() : params;
1706 contents = formatter.call(this.table.modules.format, mockCell, params, onRendered);
1708 switch (typeof contents ===
'undefined' ?
'undefined' : _typeof(contents)) {
1710 if (contents instanceof Node) {
1711 el.appendChild(contents);
1714 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);
1722 el.innerHTML = contents;
1725 el.innerHTML = title;
1730 Column.prototype._buildGroupHeader =
function () {
1733 this.element.classList.add(
"tabulator-col-group");
1734 this.element.setAttribute(
"role",
"columngroup");
1735 this.element.setAttribute(
"aria-title", this.definition.title);
1738 if (this.definition.cssClass) {
1739 var classeNames = this.definition.cssClass.split(
" ");
1740 classeNames.forEach(
function (className) {
1741 _this6.element.classList.add(className);
1745 this.element.appendChild(this.groupElement);
1749 Column.prototype._getFlatData =
function (data) {
1750 return data[this.field];
1754 Column.prototype._getNestedData =
function (data) {
1756 structure = this.fieldStructure,
1757 length = structure.length,
1760 for (var i = 0; i < length; i++) {
1762 dataObj = dataObj[structure[i]];
1775 Column.prototype._setFlatData =
function (data, value) {
1777 data[this.field] = value;
1782 Column.prototype._setNesteData =
function (data, value) {
1784 structure = this.fieldStructure,
1785 length = structure.length;
1787 for (var i = 0; i < length; i++) {
1789 if (i == length - 1) {
1790 dataObj[structure[i]] = value;
1792 if (!dataObj[structure[i]]) {
1793 dataObj[structure[i]] = {};
1796 dataObj = dataObj[structure[i]];
1802 Column.prototype.attachColumn =
function (column) {
1805 if (
self.groupElement) {
1806 self.columns.push(column);
1807 self.groupElement.appendChild(column.getElement());
1809 console.warn(
"Column Warning - Column being attached to another column instead of column group");
1814 Column.prototype.verticalAlign =
function (alignment, height) {
1817 var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : height || this.parent.getHeadersElement().clientHeight;
1820 this.element.style.height = parentHeight +
"px";
1823 this.groupElement.style.minHeight = parentHeight - this.contentElement.offsetHeight +
"px";
1827 if (!this.isGroup && alignment !==
"top") {
1828 if (alignment ===
"bottom") {
1829 this.element.style.paddingTop = this.element.clientHeight - this.contentElement.offsetHeight +
"px";
1831 this.element.style.paddingTop = (this.element.clientHeight - this.contentElement.offsetHeight) / 2 +
"px";
1835 this.columns.forEach(
function (column) {
1836 column.verticalAlign(alignment);
1841 Column.prototype.clearVerticalAlign =
function () {
1842 this.element.style.paddingTop =
"";
1843 this.element.style.height =
"";
1844 this.element.style.minHeight =
"";
1845 this.groupElement.style.minHeight =
"";
1847 this.columns.forEach(
function (column) {
1848 column.clearVerticalAlign();
1852 Column.prototype.bindModuleColumns =
function () {
1854 if (this.definition.formatter ==
"rownum") {
1855 this.table.rowManager.rowNumColumn =
this;
1862 Column.prototype.getElement =
function () {
1863 return this.element;
1867 Column.prototype.getGroupElement =
function () {
1868 return this.groupElement;
1872 Column.prototype.getField =
function () {
1877 Column.prototype.getFirstColumn =
function () {
1878 if (!this.isGroup) {
1881 if (this.columns.length) {
1882 return this.columns[0].getFirstColumn();
1890 Column.prototype.getLastColumn =
function () {
1891 if (!this.isGroup) {
1894 if (this.columns.length) {
1895 return this.columns[this.columns.length - 1].getLastColumn();
1903 Column.prototype.getColumns =
function () {
1904 return this.columns;
1908 Column.prototype.getCells =
function () {
1913 Column.prototype.getTopColumn =
function () {
1914 if (this.parent.isGroup) {
1915 return this.parent.getTopColumn();
1922 Column.prototype.getDefinition =
function (updateBranches) {
1925 if (this.isGroup && updateBranches) {
1926 this.columns.forEach(
function (column) {
1927 colDefs.push(column.getDefinition(
true));
1930 this.definition.columns = colDefs;
1933 return this.definition;
1938 Column.prototype.checkColumnVisibility =
function () {
1939 var visible =
false;
1941 this.columns.forEach(
function (column) {
1942 if (column.visible) {
1949 this.parent.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
false);
1956 Column.prototype.show =
function (silent, responsiveToggle) {
1957 if (!this.visible) {
1958 this.visible =
true;
1960 this.element.style.display =
"";
1962 if (this.parent.isGroup) {
1963 this.parent.checkColumnVisibility();
1966 this.cells.forEach(
function (cell) {
1970 if (!this.isGroup && this.width === null) {
1971 this.reinitializeWidth();
1974 this.table.columnManager._verticalAlignHeaders();
1976 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
1977 this.table.modules.persistence.save(
"columns");
1980 if (!responsiveToggle && this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
1981 this.table.modules.responsiveLayout.updateColumnVisibility(
this, this.visible);
1985 this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
true);
1988 if (this.parent.isGroup) {
1989 this.parent.matchChildWidths();
1995 Column.prototype.hide =
function (silent, responsiveToggle) {
1997 this.visible =
false;
1999 this.element.style.display =
"none";
2001 this.table.columnManager._verticalAlignHeaders();
2003 if (this.parent.isGroup) {
2004 this.parent.checkColumnVisibility();
2007 this.cells.forEach(
function (cell) {
2011 if (this.table.options.persistence &&
this.table.modExists(
"persistence",
true) && this.table.modules.persistence.config.columns) {
2012 this.table.modules.persistence.save(
"columns");
2015 if (!responsiveToggle && this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
2016 this.table.modules.responsiveLayout.updateColumnVisibility(
this, this.visible);
2020 this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(),
false);
2023 if (this.parent.isGroup) {
2024 this.parent.matchChildWidths();
2029 Column.prototype.matchChildWidths =
function () {
2032 if (this.contentElement && this.columns.length) {
2033 this.columns.forEach(
function (column) {
2034 if (column.visible) {
2035 childWidth += column.getWidth();
2039 this.contentElement.style.maxWidth = childWidth - 1 +
"px";
2043 Column.prototype.setWidth =
function (width) {
2044 this.widthFixed =
true;
2045 this.setWidthActual(width);
2048 Column.prototype.setWidthActual =
function (width) {
2050 width = Math.floor(this.table.element.clientWidth / 100 * parseInt(width));
2053 width = Math.max(this.minWidth, width);
2056 this.widthStyled = width ? width +
"px" :
"";
2058 this.element.style.width = this.widthStyled;
2060 if (!this.isGroup) {
2061 this.cells.forEach(
function (cell) {
2066 if (this.parent.isGroup) {
2067 this.parent.matchChildWidths();
2071 if (this.table.modExists(
"frozenColumns")) {
2072 this.table.modules.frozenColumns.layout();
2076 Column.prototype.checkCellHeights =
function () {
2079 this.cells.forEach(
function (cell) {
2080 if (cell.row.heightInitialized) {
2081 if (cell.row.getElement().offsetParent !== null) {
2082 rows.push(cell.row);
2083 cell.row.clearCellHeight();
2085 cell.row.heightInitialized =
false;
2090 rows.forEach(
function (row) {
2094 rows.forEach(
function (row) {
2095 row.setCellHeight();
2099 Column.prototype.getWidth =
function () {
2104 Column.prototype.getHeight =
function () {
2105 return this.element.offsetHeight;
2108 Column.prototype.setMinWidth =
function (minWidth) {
2109 this.minWidth = minWidth;
2110 this.minWidthStyled = minWidth ? minWidth +
"px" :
"";
2112 this.element.style.minWidth = this.minWidthStyled;
2114 this.cells.forEach(
function (cell) {
2119 Column.prototype.delete =
function () {
2122 return new Promise(
function (resolve, reject) {
2124 if (_this7.isGroup) {
2125 _this7.columns.forEach(function (column) {
2130 var cellCount = _this7.cells.length;
2132 for (var i = 0; i < cellCount; i++) {
2133 _this7.cells[0].delete();
2136 _this7.element.parentNode.removeChild(_this7.element);
2138 _this7.table.columnManager.deregisterColumn(_this7);
2144 Column.prototype.columnRendered =
function () {
2145 if (this.titleFormatterRendered) {
2146 this.titleFormatterRendered();
2153 Column.prototype.generateCell =
function (row) {
2156 var cell =
new Cell(
self, row);
2158 this.cells.push(cell);
2163 Column.prototype.nextColumn =
function () {
2164 var index = this.table.columnManager.findColumnIndex(
this);
2165 return index > -1 ? this._nextVisibleColumn(index + 1) : false;
2168 Column.prototype._nextVisibleColumn =
function (index) {
2169 var column = this.table.columnManager.getColumnByIndex(index);
2170 return !column || column.visible ? column : this._nextVisibleColumn(index + 1);
2173 Column.prototype.prevColumn =
function () {
2174 var index = this.table.columnManager.findColumnIndex(
this);
2175 return index > -1 ? this._prevVisibleColumn(index - 1) : false;
2178 Column.prototype._prevVisibleColumn =
function (index) {
2179 var column = this.table.columnManager.getColumnByIndex(index);
2180 return !column || column.visible ? column : this._prevVisibleColumn(index - 1);
2183 Column.prototype.reinitializeWidth =
function (force) {
2184 this.widthFixed =
false;
2187 if (typeof this.definition.width !==
"undefined" && !force) {
2188 this.setWidth(this.definition.width);
2192 if (this.table.modExists(
"filter")) {
2193 this.table.modules.filter.hideHeaderFilterElements();
2199 if (this.table.modExists(
"filter")) {
2200 this.table.modules.filter.showHeaderFilterElements();
2205 Column.prototype.fitToData =
function () {
2208 if (!this.widthFixed) {
2209 this.element.style.width =
"";
2211 self.cells.forEach(
function (cell) {
2216 var maxWidth = this.element.offsetWidth;
2218 if (!
self.width || !this.widthFixed) {
2219 self.cells.forEach(
function (cell) {
2220 var width = cell.getWidth();
2222 if (width > maxWidth) {
2228 self.setWidthActual(maxWidth + 1);
2233 Column.prototype.updateDefinition =
function (updates) {
2236 return new Promise(
function (resolve, reject) {
2239 if (!_this8.isGroup) {
2240 definition = Object.assign({}, _this8.getDefinition());
2241 definition = Object.assign(definition, updates);
2243 _this8.table.columnManager.addColumn(definition,
false, _this8).then(
function (column) {
2245 if (definition.field == _this8.field) {
2246 _this8.field =
false;
2249 _this8.delete().then(
function () {
2250 resolve(column.getComponent());
2251 }).
catch(
function (err) {
2254 }).
catch(
function (err) {
2258 console.warn(
"Column Update Error - The updateDefintion function is only available on columns, not column groups");
2259 reject(
"Column Update Error - The updateDefintion function is only available on columns, not column groups");
2264 Column.prototype.deleteCell =
function (cell) {
2265 var index = this.cells.indexOf(cell);
2268 this.cells.splice(index, 1);
2272 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"];
2277 Column.prototype.getComponent =
function () {
2278 return new ColumnComponent(
this);
2281 var RowManager =
function RowManager(table) {
2284 this.element = this.createHolderElement();
2285 this.tableElement = this.createTableElement();
2286 this.columnManager = null;
2289 this.firstRender =
false;
2290 this.renderMode =
"classic";
2293 this.activeRows = [];
2294 this.activeRowsCount = 0;
2296 this.displayRows = [];
2297 this.displayRowsCount = 0;
2300 this.scrollLeft = 0;
2302 this.vDomRowHeight = 20;
2305 this.vDomBottom = 0;
2307 this.vDomScrollPosTop = 0;
2308 this.vDomScrollPosBottom = 0;
2310 this.vDomTopPad = 0;
2311 this.vDomBottomPad = 0;
2313 this.vDomMaxRenderChain = 90;
2315 this.vDomWindowBuffer = 0;
2317 this.vDomWindowMinTotalRows = 20;
2318 this.vDomWindowMinMarginRows = 5;
2320 this.vDomTopNewRows = [];
2321 this.vDomBottomNewRows = [];
2323 this.rowNumColumn =
false;
2325 this.redrawBlock =
false;
2326 this.redrawBlockRestoreConfig =
false;
2327 this.redrawBlockRederInPosition =
false;
2332 RowManager.prototype.createHolderElement =
function () {
2333 var el = document.createElement(
"div");
2335 el.classList.add(
"tabulator-tableHolder");
2336 el.setAttribute(
"tabindex", 0);
2341 RowManager.prototype.createTableElement =
function () {
2342 var el = document.createElement(
"div");
2344 el.classList.add(
"tabulator-table");
2350 RowManager.prototype.getElement =
function () {
2351 return this.element;
2355 RowManager.prototype.getTableElement =
function () {
2356 return this.tableElement;
2360 RowManager.prototype.getRowPosition =
function (row, active) {
2362 return this.activeRows.indexOf(row);
2364 return this.rows.indexOf(row);
2369 RowManager.prototype.setColumnManager =
function (manager) {
2370 this.columnManager = manager;
2373 RowManager.prototype.initialize =
function () {
2376 self.setRenderMode();
2379 self.element.appendChild(
self.tableElement);
2381 self.firstRender =
true;
2384 self.element.addEventListener(
"scroll",
function () {
2385 var left =
self.element.scrollLeft;
2388 if (
self.scrollLeft != left) {
2389 self.columnManager.scrollHorizontal(left);
2391 if (
self.table.options.groupBy) {
2392 self.table.modules.groupRows.scrollHeaders(left);
2395 if (
self.table.modExists(
"columnCalcs")) {
2396 self.table.modules.columnCalcs.scrollHorizontal(left);
2399 self.table.options.scrollHorizontal(left);
2402 self.scrollLeft = left;
2406 if (this.renderMode ===
"virtual") {
2408 self.element.addEventListener(
"scroll",
function () {
2409 var top =
self.element.scrollTop;
2410 var dir =
self.scrollTop > top;
2413 if (
self.scrollTop != top) {
2414 self.scrollTop = top;
2415 self.scrollVertical(dir);
2417 if (
self.table.options.ajaxProgressiveLoad ==
"scroll") {
2418 self.table.modules.ajax.nextPage(
self.element.scrollHeight -
self.element.clientHeight - top);
2421 self.table.options.scrollVertical(top);
2423 self.scrollTop = top;
2431 RowManager.prototype.findRow =
function (subject) {
2434 if ((typeof subject ===
'undefined' ?
'undefined' : _typeof(subject)) ==
"object") {
2436 if (subject instanceof Row) {
2439 }
else if (subject instanceof RowComponent) {
2441 return subject._getSelf() ||
false;
2442 }
else if (typeof HTMLElement !==
"undefined" && subject instanceof HTMLElement) {
2444 var match =
self.rows.find(
function (row) {
2445 return row.element === subject;
2448 return match ||
false;
2450 }
else if (typeof subject ==
"undefined" || subject === null) {
2454 var _match =
self.rows.find(
function (row) {
2455 return row.data[
self.table.options.index] == subject;
2458 return _match ||
false;
2466 RowManager.prototype.getRowFromDataObject =
function (data) {
2467 var match = this.rows.find(
function (row) {
2468 return row.data === data;
2471 return match ||
false;
2474 RowManager.prototype.getRowFromPosition =
function (position, active) {
2476 return this.activeRows[position];
2478 return this.rows[position];
2482 RowManager.prototype.scrollToRow =
function (row, position, ifVisible) {
2485 var rowIndex = this.getDisplayRows().indexOf(row),
2486 rowEl = row.getElement(),
2490 return new Promise(
function (resolve, reject) {
2491 if (rowIndex > -1) {
2493 if (typeof position ===
"undefined") {
2494 position = _this9.table.options.scrollToRowPosition;
2497 if (typeof ifVisible ===
"undefined") {
2498 ifVisible = _this9.table.options.scrollToRowIfVisible;
2501 if (position ===
"nearest") {
2502 switch (_this9.renderMode) {
2504 rowTop = Tabulator.prototype.helpers.elOffset(rowEl).top;
2505 position = Math.abs(_this9.element.scrollTop - rowTop) > Math.abs(_this9.element.scrollTop + _this9.element.clientHeight - rowTop) ?
"bottom" :
"top";
2508 position = Math.abs(_this9.vDomTop - rowIndex) > Math.abs(_this9.vDomBottom - rowIndex) ?
"bottom" :
"top";
2515 if (Tabulator.prototype.helpers.elVisible(rowEl)) {
2516 offset = Tabulator.prototype.helpers.elOffset(rowEl).top - Tabulator.prototype.helpers.elOffset(_this9.element).top;
2518 if (offset > 0 && offset < _this9.element.clientHeight - rowEl.offsetHeight) {
2525 switch (_this9.renderMode) {
2527 _this9.element.scrollTop = Tabulator.prototype.helpers.elOffset(rowEl).top - Tabulator.prototype.helpers.elOffset(_this9.element).top + _this9.element.scrollTop;
2530 _this9._virtualRenderFill(rowIndex,
true);
2539 if (_this9.element.scrollHeight - _this9.element.scrollTop == _this9.element.clientHeight) {
2540 _this9.element.scrollTop = _this9.element.scrollTop + (rowEl.offsetTop - _this9.element.scrollTop) - (_this9.element.scrollHeight - rowEl.offsetTop) / 2;
2542 _this9.element.scrollTop = _this9.element.scrollTop - _this9.element.clientHeight / 2;
2549 if (_this9.element.scrollHeight - _this9.element.scrollTop == _this9.element.clientHeight) {
2550 _this9.element.scrollTop = _this9.element.scrollTop - (_this9.element.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight;
2552 _this9.element.scrollTop = _this9.element.scrollTop - _this9.element.clientHeight + rowEl.offsetHeight;
2560 console.warn(
"Scroll Error - Row not visible");
2561 reject(
"Scroll Error - Row not visible");
2568 RowManager.prototype.setData =
function (data, renderInPosition) {
2573 return new Promise(
function (resolve, reject) {
2574 if (renderInPosition && _this10.getDisplayRows().length) {
2575 if (
self.table.options.pagination) {
2576 self._setDataActual(data,
true);
2578 _this10.reRenderInPosition(
function () {
2579 self._setDataActual(data);
2583 if (_this10.table.options.autoColumns) {
2584 _this10.table.columnManager.generateColumnsFromRowData(data);
2586 _this10.resetScroll();
2587 _this10._setDataActual(data);
2594 RowManager.prototype._setDataActual =
function (data, renderInPosition) {
2597 self.table.options.dataLoading.call(this.table, data);
2599 this._wipeElements();
2601 if (this.table.options.history &&
this.table.modExists(
"history")) {
2602 this.table.modules.history.clear();
2605 if (Array.isArray(data)) {
2607 if (this.table.modExists(
"selectRow")) {
2608 this.table.modules.selectRow.clearSelectionData();
2611 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {
2612 this.table.modules.reactiveData.watchData(data);
2615 data.forEach(
function (def, i) {
2616 if (def && (typeof def ===
'undefined' ?
'undefined' : _typeof(def)) ===
"object") {
2617 var row =
new Row(def,
self);
2618 self.rows.push(row);
2620 console.warn(
"Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);
2624 self.table.options.dataLoaded.call(this.table, data);
2626 self.refreshActiveData(
false,
false, renderInPosition);
2628 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);
2632 RowManager.prototype._wipeElements =
function () {
2633 this.rows.forEach(
function (row) {
2637 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
2638 this.table.modules.groupRows.wipe();
2644 RowManager.prototype.deleteRow =
function (row, blockRedraw) {
2645 var allIndex = this.rows.indexOf(row),
2646 activeIndex = this.activeRows.indexOf(row);
2648 if (activeIndex > -1) {
2649 this.activeRows.splice(activeIndex, 1);
2652 if (allIndex > -1) {
2653 this.rows.splice(allIndex, 1);
2656 this.setActiveRows(this.activeRows);
2658 this.displayRowIterator(
function (rows) {
2659 var displayIndex = rows.indexOf(row);
2661 if (displayIndex > -1) {
2662 rows.splice(displayIndex, 1);
2667 this.reRenderInPosition();
2670 this.table.options.rowDeleted.call(this.table, row.getComponent());
2672 this.table.options.dataEdited.call(this.table, this.getData());
2674 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
2675 this.table.modules.groupRows.updateGroupRows(
true);
2676 }
else if (this.table.options.pagination &&
this.table.modExists(
"page")) {
2677 this.refreshActiveData(
false,
false,
true);
2679 if (this.table.options.pagination &&
this.table.modExists(
"page")) {
2680 this.refreshActiveData(
"page");
2685 RowManager.prototype.addRow =
function (data, pos, index, blockRedraw) {
2687 var row = this.addRowActual(data, pos, index, blockRedraw);
2689 if (this.table.options.history &&
this.table.modExists(
"history")) {
2690 this.table.modules.history.action(
"rowAdd", row, { data: data, pos: pos, index: index });
2697 RowManager.prototype.addRows =
function (data, pos, index) {
2704 return new Promise(
function (resolve, reject) {
2705 pos = _this11.findAddRowPos(pos);
2707 if (!Array.isArray(data)) {
2711 length = data.length - 1;
2713 if (typeof index ==
"undefined" && pos || typeof index !==
"undefined" && !pos) {
2717 data.forEach(
function (item, i) {
2718 var row =
self.addRow(item, pos, index,
true);
2722 if (_this11.table.options.groupBy && _this11.table.modExists(
"groupRows")) {
2723 _this11.table.modules.groupRows.updateGroupRows(
true);
2724 }
else if (_this11.table.options.pagination && _this11.table.modExists(
"page")) {
2725 _this11.refreshActiveData(
false,
false,
true);
2727 _this11.reRenderInPosition();
2731 if (_this11.table.modExists(
"columnCalcs")) {
2732 _this11.table.modules.columnCalcs.recalc(_this11.table.rowManager.activeRows);
2739 RowManager.prototype.findAddRowPos =
function (pos) {
2740 if (typeof pos ===
"undefined") {
2741 pos = this.table.options.addRowPos;
2744 if (pos ===
"pos") {
2748 if (pos ===
"bottom") {
2755 RowManager.prototype.addRowActual =
function (data, pos, index, blockRedraw) {
2756 var row = data instanceof Row ? data :
new Row(data || {},
this),
2757 top = this.findAddRowPos(pos),
2760 if (!index && this.table.options.pagination &&
this.table.options.paginationAddRow ==
"page") {
2761 dispRows = this.getDisplayRows();
2764 if (dispRows.length) {
2765 index = dispRows[0];
2767 if (this.activeRows.length) {
2768 index = this.activeRows[this.activeRows.length - 1];
2773 if (dispRows.length) {
2774 index = dispRows[dispRows.length - 1];
2775 top = dispRows.length < this.table.modules.page.getPageSize() ?
false :
true;
2781 index = this.findRow(index);
2784 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
2785 this.table.modules.groupRows.assignRowToGroup(row);
2787 var groupRows = row.getGroup().rows;
2789 if (groupRows.length > 1) {
2791 if (!index || index && groupRows.indexOf(index) == -1) {
2793 if (groupRows[0] !== row) {
2794 index = groupRows[0];
2795 this._moveRowInArray(row.getGroup().rows, row, index, !top);
2798 if (groupRows[groupRows.length - 1] !== row) {
2799 index = groupRows[groupRows.length - 1];
2800 this._moveRowInArray(row.getGroup().rows, row, index, !top);
2804 this._moveRowInArray(row.getGroup().rows, row, index, !top);
2810 var allIndex = this.rows.indexOf(index),
2811 activeIndex = this.activeRows.indexOf(index);
2813 this.displayRowIterator(
function (rows) {
2814 var displayIndex = rows.indexOf(index);
2816 if (displayIndex > -1) {
2817 rows.splice(top ? displayIndex : displayIndex + 1, 0, row);
2821 if (activeIndex > -1) {
2822 this.activeRows.splice(top ? activeIndex : activeIndex + 1, 0, row);
2825 if (allIndex > -1) {
2826 this.rows.splice(top ? allIndex : allIndex + 1, 0, row);
2832 this.displayRowIterator(
function (rows) {
2836 this.activeRows.unshift(row);
2837 this.rows.unshift(row);
2839 this.displayRowIterator(
function (rows) {
2843 this.activeRows.push(row);
2844 this.rows.push(row);
2848 this.setActiveRows(this.activeRows);
2850 this.table.options.rowAdded.call(this.table, row.getComponent());
2852 this.table.options.dataEdited.call(this.table, this.getData());
2855 this.reRenderInPosition();
2861 RowManager.prototype.moveRow =
function (from, to, after) {
2862 if (this.table.options.history &&
this.table.modExists(
"history")) {
2863 this.table.modules.history.action(
"rowMove", from, { pos: this.getRowPosition(from), to: to, after: after });
2866 this.moveRowActual(from, to, after);
2868 this.table.options.rowMoved.call(this.table, from.getComponent());
2871 RowManager.prototype.moveRowActual =
function (from, to, after) {
2873 this._moveRowInArray(this.rows, from, to, after);
2874 this._moveRowInArray(this.activeRows, from, to, after);
2876 this.displayRowIterator(
function (rows) {
2877 self._moveRowInArray(rows, from, to, after);
2880 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
2881 var toGroup = to.getGroup();
2882 var fromGroup = from.getGroup();
2884 if (toGroup === fromGroup) {
2885 this._moveRowInArray(toGroup.rows, from, to, after);
2888 fromGroup.removeRow(from);
2891 toGroup.insertRow(from, to, after);
2896 RowManager.prototype._moveRowInArray =
function (rows, from, to, after) {
2897 var fromIndex, toIndex, start, end;
2901 fromIndex = rows.indexOf(from);
2903 if (fromIndex > -1) {
2905 rows.splice(fromIndex, 1);
2907 toIndex = rows.indexOf(to);
2912 rows.splice(toIndex + 1, 0, from);
2914 rows.splice(toIndex, 0, from);
2917 rows.splice(fromIndex, 0, from);
2922 if (rows === this.getDisplayRows()) {
2924 start = fromIndex < toIndex ? fromIndex : toIndex;
2925 end = toIndex > fromIndex ? toIndex : fromIndex + 1;
2927 for (var i = start; i <= end; i++) {
2929 this.styleRow(rows[i], i);
2936 RowManager.prototype.clearData =
function () {
2940 RowManager.prototype.getRowIndex =
function (row) {
2941 return this.findRowIndex(row, this.rows);
2944 RowManager.prototype.getDisplayRowIndex =
function (row) {
2945 var index = this.getDisplayRows().indexOf(row);
2946 return index > -1 ? index :
false;
2949 RowManager.prototype.nextDisplayRow =
function (row, rowOnly) {
2950 var index = this.getDisplayRowIndex(row),
2953 if (index !==
false && index < this.displayRowsCount - 1) {
2954 nextRow = this.getDisplayRows()[index + 1];
2957 if (nextRow && (!(nextRow instanceof Row) || nextRow.type !=
"row")) {
2958 return this.nextDisplayRow(nextRow, rowOnly);
2964 RowManager.prototype.prevDisplayRow =
function (row, rowOnly) {
2965 var index = this.getDisplayRowIndex(row),
2969 prevRow = this.getDisplayRows()[index - 1];
2972 if (prevRow && (!(prevRow instanceof Row) || prevRow.type !=
"row")) {
2973 return this.prevDisplayRow(prevRow, rowOnly);
2979 RowManager.prototype.findRowIndex =
function (row, list) {
2982 row = this.findRow(row);
2985 rowIndex = list.indexOf(row);
2987 if (rowIndex > -1) {
2995 RowManager.prototype.getData =
function (active, transform) {
2997 rows = this.getRows(active);
2999 rows.forEach(
function (row) {
3000 output.push(row.getData(transform ||
"data"));
3006 RowManager.prototype.getComponents =
function (active) {
3008 rows = this.getRows(active);
3010 rows.forEach(
function (row) {
3011 output.push(row.getComponent());
3017 RowManager.prototype.getDataCount =
function (active) {
3018 var rows = this.getRows(active);
3023 RowManager.prototype._genRemoteRequest =
function () {
3026 options = table.options,
3029 if (table.modExists(
"page")) {
3031 if (options.ajaxSorting) {
3032 var sorters =
self.table.modules.sort.getSort();
3034 sorters.forEach(
function (item) {
3038 params[
self.table.modules.page.paginationDataSentNames.sorters] = sorters;
3042 if (options.ajaxFiltering) {
3043 var filters =
self.table.modules.filter.getFilters(
true,
true);
3045 params[
self.table.modules.page.paginationDataSentNames.filters] = filters;
3048 self.table.modules.ajax.setParams(params,
true);
3051 table.modules.ajax.sendRequest().then(
function (data) {
3053 }).
catch(
function (e) {});
3057 RowManager.prototype.filterRefresh =
function () {
3058 var table = this.table,
3059 options = table.options,
3060 left = this.scrollLeft;
3062 if (options.ajaxFiltering) {
3063 if (options.pagination ==
"remote" && table.modExists(
"page")) {
3064 table.modules.page.reset(
true);
3065 table.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
3066 }
else if (options.ajaxProgressiveLoad) {
3067 table.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
3070 this._genRemoteRequest();
3073 this.refreshActiveData(
"filter");
3076 this.scrollHorizontal(left);
3080 RowManager.prototype.sorterRefresh =
function (loadOrignalData) {
3081 var table = this.table,
3082 options = this.table.options,
3083 left = this.scrollLeft;
3085 if (options.ajaxSorting) {
3086 if ((options.pagination ==
"remote" || options.progressiveLoad) && table.modExists(
"page")) {
3087 table.modules.page.reset(
true);
3088 table.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
3089 }
else if (options.ajaxProgressiveLoad) {
3090 table.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
3093 this._genRemoteRequest();
3096 this.refreshActiveData(loadOrignalData ?
"filter" :
"sort");
3099 this.scrollHorizontal(left);
3102 RowManager.prototype.scrollHorizontal =
function (left) {
3103 this.scrollLeft = left;
3104 this.element.scrollLeft = left;
3106 if (this.table.options.groupBy) {
3107 this.table.modules.groupRows.scrollHeaders(left);
3110 if (this.table.modExists(
"columnCalcs")) {
3111 this.table.modules.columnCalcs.scrollHorizontal(left);
3116 RowManager.prototype.refreshActiveData =
function (stage, skipStage, renderInPosition) {
3121 cascadeOrder = [
"all",
"filter",
"sort",
"display",
"freeze",
"group",
"tree",
"page"],
3124 if (this.redrawBlock) {
3126 if (!this.redrawBlockRestoreConfig || cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage)) {
3127 this.redrawBlockRestoreConfig = {
3129 skipStage: skipStage,
3130 renderInPosition: renderInPosition
3137 if (
self.table.modExists(
"edit")) {
3138 self.table.modules.edit.cancelEdit();
3145 if (table.options.selectable && !table.options.selectablePersistence && table.modExists(
"selectRow")) {
3146 table.modules.selectRow.deselectRows();
3155 if (table.modExists(
"filter")) {
3156 self.setActiveRows(table.modules.filter.filter(
self.rows));
3158 self.setActiveRows(
self.rows.slice(0));
3166 if (table.modExists(
"sort")) {
3167 table.modules.sort.sort(this.activeRows);
3174 if (this.rowNumColumn) {
3175 this.activeRows.forEach(
function (row) {
3176 var cell = row.getCell(_this12.rowNumColumn);
3179 cell._generateContents();
3186 this.resetDisplayRows();
3190 if (this.table.modExists(
"frozenRows")) {
3191 if (table.modules.frozenRows.isFrozen()) {
3192 if (!table.modules.frozenRows.getDisplayIndex()) {
3193 table.modules.frozenRows.setDisplayIndex(this.getNextDisplayIndex());
3196 displayIndex = table.modules.frozenRows.getDisplayIndex();
3198 displayIndex =
self.setDisplayRows(table.modules.frozenRows.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
3200 if (displayIndex !==
true) {
3201 table.modules.frozenRows.setDisplayIndex(displayIndex);
3211 if (table.options.groupBy && table.modExists(
"groupRows")) {
3213 if (!table.modules.groupRows.getDisplayIndex()) {
3214 table.modules.groupRows.setDisplayIndex(this.getNextDisplayIndex());
3217 displayIndex = table.modules.groupRows.getDisplayIndex();
3219 displayIndex =
self.setDisplayRows(table.modules.groupRows.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
3221 if (displayIndex !==
true) {
3222 table.modules.groupRows.setDisplayIndex(displayIndex);
3232 if (table.options.dataTree && table.modExists(
"dataTree")) {
3233 if (!table.modules.dataTree.getDisplayIndex()) {
3234 table.modules.dataTree.setDisplayIndex(this.getNextDisplayIndex());
3237 displayIndex = table.modules.dataTree.getDisplayIndex();
3239 displayIndex =
self.setDisplayRows(table.modules.dataTree.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
3241 if (displayIndex !==
true) {
3242 table.modules.dataTree.setDisplayIndex(displayIndex);
3249 if (table.options.pagination && table.modExists(
"page") && !renderInPosition) {
3250 if (table.modules.page.getMode() ==
"local") {
3251 table.modules.page.reset();
3257 if (table.options.pagination && table.modExists(
"page")) {
3259 if (!table.modules.page.getDisplayIndex()) {
3260 table.modules.page.setDisplayIndex(this.getNextDisplayIndex());
3263 displayIndex = table.modules.page.getDisplayIndex();
3265 if (table.modules.page.getMode() ==
"local") {
3266 table.modules.page.setMaxRows(this.getDisplayRows(displayIndex - 1).length);
3269 displayIndex =
self.setDisplayRows(table.modules.page.getRows(
this.getDisplayRows(displayIndex - 1)), displayIndex);
3271 if (displayIndex !==
true) {
3272 table.modules.page.setDisplayIndex(displayIndex);
3280 if (Tabulator.prototype.helpers.elVisible(
self.element)) {
3281 if (renderInPosition) {
3282 self.reRenderInPosition();
3285 if (table.options.layoutColumnsOnNewData) {
3286 self.table.columnManager.redraw(
true);
3291 if (table.modExists(
"columnCalcs")) {
3292 table.modules.columnCalcs.recalc(this.activeRows);
3297 RowManager.prototype.setActiveRows =
function (activeRows) {
3298 this.activeRows = activeRows;
3299 this.activeRowsCount = this.activeRows.length;
3303 RowManager.prototype.resetDisplayRows =
function () {
3304 this.displayRows = [];
3306 this.displayRows.push(this.activeRows.slice(0));
3308 this.displayRowsCount = this.displayRows[0].length;
3310 if (this.table.modExists(
"frozenRows")) {
3311 this.table.modules.frozenRows.setDisplayIndex(0);
3314 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
3315 this.table.modules.groupRows.setDisplayIndex(0);
3318 if (this.table.options.pagination &&
this.table.modExists(
"page")) {
3319 this.table.modules.page.setDisplayIndex(0);
3323 RowManager.prototype.getNextDisplayIndex =
function () {
3324 return this.displayRows.length;
3328 RowManager.prototype.setDisplayRows =
function (displayRows, index) {
3332 if (index && typeof this.displayRows[index] !=
"undefined") {
3333 this.displayRows[index] = displayRows;
3336 this.displayRows.push(displayRows);
3337 output = index = this.displayRows.length - 1;
3340 if (index == this.displayRows.length - 1) {
3341 this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
3347 RowManager.prototype.getDisplayRows =
function (index) {
3348 if (typeof index ==
"undefined") {
3349 return this.displayRows.length ? this.displayRows[this.displayRows.length - 1] : [];
3351 return this.displayRows[index] || [];
3355 RowManager.prototype.getVisibleRows =
function (viewable) {
3356 var topEdge = this.element.scrollTop,
3357 bottomEdge = this.element.clientHeight + topEdge,
3361 rows = this.getDisplayRows();
3365 this.getDisplayRows();
3366 for (var i = this.vDomTop; i <= this.vDomBottom; i++) {
3369 if (topEdge - rows[i].getElement().offsetTop >= 0) {
3374 if (bottomEdge - rows[i].getElement().offsetTop >= 0) {
3381 if (bottomEdge - rows[i].getElement().offsetTop >= 0) {
3390 topRow = this.vDomTop;
3391 bottomRow = this.vDomBottom;
3394 return rows.slice(topRow, bottomRow + 1);
3398 RowManager.prototype.displayRowIterator =
function (callback) {
3399 this.displayRows.forEach(callback);
3401 this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length;
3405 RowManager.prototype.getRows =
function (active) {
3410 rows = this.activeRows;
3414 rows = this.getVisibleRows(
true);
3427 RowManager.prototype.reRenderInPosition =
function (callback) {
3428 if (this.getRenderMode() ==
"virtual") {
3430 if (this.redrawBlock) {
3434 this.redrawBlockRederInPosition =
true;
3437 var scrollTop = this.element.scrollTop;
3439 var topOffset =
false;
3441 var left = this.scrollLeft;
3443 var rows = this.getDisplayRows();
3445 for (var i = this.vDomTop; i <= this.vDomBottom; i++) {
3448 var diff = scrollTop - rows[i].getElement().offsetTop;
3450 if (topOffset ===
false || Math.abs(diff) < topOffset) {
3463 this._virtualRenderFill(topRow ===
false ? this.displayRowsCount - 1 : topRow,
true, topOffset || 0);
3465 this.scrollHorizontal(left);
3476 RowManager.prototype.setRenderMode =
function () {
3477 if ((this.table.element.clientHeight ||
this.table.options.height) && this.table.options.virtualDom) {
3478 this.renderMode =
"virtual";
3480 this.renderMode =
"classic";
3484 RowManager.prototype.getRenderMode =
function () {
3485 return this.renderMode;
3488 RowManager.prototype.renderTable =
function () {
3491 self.table.options.renderStarted.call(this.table);
3493 self.element.scrollTop = 0;
3495 switch (
self.renderMode) {
3497 self._simpleRender();
3501 self._virtualRenderFill();
3505 if (
self.firstRender) {
3506 if (
self.displayRowsCount) {
3507 self.firstRender =
false;
3508 self.table.modules.layout.layout();
3510 self.renderEmptyScroll();
3514 if (
self.table.modExists(
"frozenColumns")) {
3515 self.table.modules.frozenColumns.layout();
3518 if (!
self.displayRowsCount) {
3519 if (
self.table.options.placeholder) {
3521 if (this.renderMode) {
3522 self.table.options.placeholder.setAttribute(
"tabulator-render-mode", this.renderMode);
3525 self.getElement().appendChild(
self.table.options.placeholder);
3529 self.table.options.renderComplete.call(this.table);
3533 RowManager.prototype._simpleRender =
function () {
3534 this._clearVirtualDom();
3536 if (this.displayRowsCount) {
3537 this.checkClassicModeGroupHeaderWidth();
3539 this.renderEmptyScroll();
3543 RowManager.prototype.checkClassicModeGroupHeaderWidth =
function () {
3545 element = this.tableElement,
3546 onlyGroupHeaders =
true;
3548 self.getDisplayRows().forEach(
function (row, index) {
3549 self.styleRow(row, index);
3550 element.appendChild(row.getElement());
3551 row.initialize(
true);
3553 if (row.type !==
"group") {
3554 onlyGroupHeaders =
false;
3558 if (onlyGroupHeaders) {
3559 element.style.minWidth =
self.table.columnManager.getWidth() +
"px";
3561 element.style.minWidth =
"";
3566 RowManager.prototype.renderEmptyScroll =
function () {
3567 this.tableElement.style.minWidth = this.table.columnManager.getWidth() +
"px";
3568 this.tableElement.style.minHeight =
"1px";
3569 this.tableElement.style.visibility =
"hidden";
3572 RowManager.prototype._clearVirtualDom =
function () {
3573 var element = this.tableElement;
3575 if (this.table.options.placeholder &&
this.table.options.placeholder.parentNode) {
3576 this.table.options.placeholder.parentNode.removeChild(this.table.options.placeholder);
3580 while (element.firstChild) {
3581 element.removeChild(element.firstChild);
3582 }element.style.paddingTop =
"";
3583 element.style.paddingBottom =
"";
3584 element.style.minWidth =
"";
3585 element.style.minHeight =
"";
3586 element.style.visibility =
"";
3589 this.scrollLeft = 0;
3591 this.vDomBottom = 0;
3592 this.vDomTopPad = 0;
3593 this.vDomBottomPad = 0;
3596 RowManager.prototype.styleRow =
function (row, index) {
3597 var rowEl = row.getElement();
3600 rowEl.classList.add(
"tabulator-row-even");
3601 rowEl.classList.remove(
"tabulator-row-odd");
3603 rowEl.classList.add(
"tabulator-row-odd");
3604 rowEl.classList.remove(
"tabulator-row-even");
3609 RowManager.prototype._virtualRenderFill =
function (position, forceMove, offset) {
3611 element =
self.tableElement,
3612 holder =
self.element,
3617 onlyGroupHeaders =
true,
3618 rows =
self.getDisplayRows();
3620 position = position || 0;
3622 offset = offset || 0;
3625 self._clearVirtualDom();
3627 while (element.firstChild) {
3628 element.removeChild(element.firstChild);
3630 var heightOccupied = (
self.displayRowsCount - position + 1) *
self.vDomRowHeight;
3632 if (heightOccupied <
self.height) {
3633 position -= Math.ceil((
self.height - heightOccupied) /
self.vDomRowHeight);
3641 topPad = Math.min(Math.max(Math.floor(
self.vDomWindowBuffer /
self.vDomRowHeight),
self.vDomWindowMinMarginRows), position);
3645 if (
self.displayRowsCount && Tabulator.prototype.helpers.elVisible(
self.element)) {
3647 self.vDomTop = position;
3649 self.vDomBottom = position - 1;
3651 while ((rowsHeight <=
self.height +
self.vDomWindowBuffer || i <
self.vDomWindowMinTotalRows) &&
self.vDomBottom <
self.displayRowsCount - 1) {
3652 var index =
self.vDomBottom + 1,
3656 self.styleRow(row, index);
3658 element.appendChild(row.getElement());
3659 if (!row.initialized) {
3660 row.initialize(
true);
3662 if (!row.heightInitialized) {
3663 row.normalizeHeight(
true);
3667 rowHeight = row.getHeight();
3670 topPadHeight += rowHeight;
3672 rowsHeight += rowHeight;
3675 if (rowHeight > this.vDomWindowBuffer) {
3676 this.vDomWindowBuffer = rowHeight * 2;
3679 if (row.type !==
"group") {
3680 onlyGroupHeaders =
false;
3688 this.vDomTopPad = 0;
3690 self.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / i);
3691 self.vDomBottomPad =
self.vDomRowHeight * (
self.displayRowsCount -
self.vDomBottom - 1);
3693 self.vDomScrollHeight = topPadHeight + rowsHeight +
self.vDomBottomPad -
self.height;
3695 self.vDomTopPad = !forceMove ?
self.scrollTop - topPadHeight :
self.vDomRowHeight * this.vDomTop + offset;
3696 self.vDomBottomPad =
self.vDomBottom ==
self.displayRowsCount - 1 ? 0 : Math.max(
self.vDomScrollHeight -
self.vDomTopPad - rowsHeight - topPadHeight, 0);
3699 element.style.paddingTop =
self.vDomTopPad +
"px";
3700 element.style.paddingBottom =
self.vDomBottomPad +
"px";
3703 this.scrollTop =
self.vDomTopPad + topPadHeight + offset - (this.element.scrollWidth > this.element.clientWidth ? this.element.offsetHeight - this.element.clientHeight : 0);
3706 this.scrollTop = Math.min(this.scrollTop, this.element.scrollHeight -
this.height);
3709 if (this.element.scrollWidth >
this.element.offsetWidth && forceMove) {
3710 this.scrollTop += this.element.offsetHeight - this.element.clientHeight;
3713 this.vDomScrollPosTop = this.scrollTop;
3714 this.vDomScrollPosBottom = this.scrollTop;
3716 holder.scrollTop = this.scrollTop;
3718 element.style.minWidth = onlyGroupHeaders ?
self.table.columnManager.getWidth() +
"px" :
"";
3720 if (
self.table.options.groupBy) {
3721 if (
self.table.modules.layout.getMode() !=
"fitDataFill" &&
self.displayRowsCount ==
self.table.modules.groupRows.countGroups()) {
3722 self.tableElement.style.minWidth =
self.table.columnManager.getWidth();
3726 this.renderEmptyScroll();
3731 RowManager.prototype.scrollVertical =
function (dir) {
3732 var topDiff = this.scrollTop - this.vDomScrollPosTop;
3733 var bottomDiff = this.scrollTop - this.vDomScrollPosBottom;
3734 var margin = this.vDomWindowBuffer * 2;
3736 if (-topDiff > margin || bottomDiff > margin) {
3738 var left = this.scrollLeft;
3739 this._virtualRenderFill(Math.floor(
this.element.scrollTop /
this.element.scrollHeight *
this.displayRowsCount));
3740 this.scrollHorizontal(left);
3746 this._addTopRow(-topDiff);
3749 if (bottomDiff < 0) {
3752 if (this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer) {
3753 this._removeBottomRow(-bottomDiff);
3761 if (this.scrollTop > this.vDomWindowBuffer) {
3762 this._removeTopRow(topDiff);
3766 if (bottomDiff >= 0) {
3767 this._addBottomRow(bottomDiff);
3773 RowManager.prototype._addTopRow =
function (topDiff) {
3774 var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3776 var table = this.tableElement,
3777 rows = this.getDisplayRows();
3780 var index = this.vDomTop - 1,
3781 topRow = rows[index],
3782 topRowHeight = topRow.getHeight() || this.vDomRowHeight;
3785 if (topDiff >= topRowHeight) {
3786 this.styleRow(topRow, index);
3787 table.insertBefore(topRow.getElement(), table.firstChild);
3788 if (!topRow.initialized || !topRow.heightInitialized) {
3789 this.vDomTopNewRows.push(topRow);
3791 if (!topRow.heightInitialized) {
3792 topRow.clearCellHeight();
3795 topRow.initialize();
3797 this.vDomTopPad -= topRowHeight;
3799 if (this.vDomTopPad < 0) {
3800 this.vDomTopPad = index * this.vDomRowHeight;
3804 this.vDomTopPad = 0;
3807 table.style.paddingTop = this.vDomTopPad +
"px";
3808 this.vDomScrollPosTop -= topRowHeight;
3812 topDiff = -(this.scrollTop - this.vDomScrollPosTop);
3814 if (topRow.getHeight() > this.vDomWindowBuffer) {
3815 this.vDomWindowBuffer = topRow.getHeight() * 2;
3818 if (i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (rows[this.vDomTop - 1].getHeight() || this.vDomRowHeight)) {
3819 this._addTopRow(topDiff, i + 1);
3821 this._quickNormalizeRowHeight(this.vDomTopNewRows);
3826 RowManager.prototype._removeTopRow =
function (topDiff) {
3827 var table = this.tableElement,
3828 topRow = this.getDisplayRows()[this.vDomTop],
3829 topRowHeight = topRow.getHeight() || this.vDomRowHeight;
3831 if (topDiff >= topRowHeight) {
3833 var rowEl = topRow.getElement();
3834 rowEl.parentNode.removeChild(rowEl);
3836 this.vDomTopPad += topRowHeight;
3837 table.style.paddingTop = this.vDomTopPad +
"px";
3838 this.vDomScrollPosTop += this.vDomTop ? topRowHeight : topRowHeight + this.vDomWindowBuffer;
3841 topDiff = this.scrollTop - this.vDomScrollPosTop;
3843 this._removeTopRow(topDiff);
3847 RowManager.prototype._addBottomRow =
function (bottomDiff) {
3848 var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3850 var table = this.tableElement,
3851 rows = this.getDisplayRows();
3853 if (this.vDomBottom < this.displayRowsCount - 1) {
3854 var index = this.vDomBottom + 1,
3855 bottomRow = rows[index],
3856 bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
3859 if (bottomDiff >= bottomRowHeight) {
3860 this.styleRow(bottomRow, index);
3861 table.appendChild(bottomRow.getElement());
3863 if (!bottomRow.initialized || !bottomRow.heightInitialized) {
3864 this.vDomBottomNewRows.push(bottomRow);
3866 if (!bottomRow.heightInitialized) {
3867 bottomRow.clearCellHeight();
3871 bottomRow.initialize();
3873 this.vDomBottomPad -= bottomRowHeight;
3875 if (this.vDomBottomPad < 0 || index == this.displayRowsCount - 1) {
3876 this.vDomBottomPad = 0;
3879 table.style.paddingBottom = this.vDomBottomPad +
"px";
3880 this.vDomScrollPosBottom += bottomRowHeight;
3884 bottomDiff = this.scrollTop - this.vDomScrollPosBottom;
3886 if (bottomRow.getHeight() > this.vDomWindowBuffer) {
3887 this.vDomWindowBuffer = bottomRow.getHeight() * 2;
3890 if (i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount - 1 && bottomDiff >= (rows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)) {
3891 this._addBottomRow(bottomDiff, i + 1);
3893 this._quickNormalizeRowHeight(this.vDomBottomNewRows);
3898 RowManager.prototype._removeBottomRow =
function (bottomDiff) {
3899 var table = this.tableElement,
3900 bottomRow = this.getDisplayRows()[this.vDomBottom],
3901 bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;
3903 if (bottomDiff >= bottomRowHeight) {
3905 var rowEl = bottomRow.getElement();
3907 if (rowEl.parentNode) {
3908 rowEl.parentNode.removeChild(rowEl);
3911 this.vDomBottomPad += bottomRowHeight;
3913 if (this.vDomBottomPad < 0) {
3914 this.vDomBottomPad = 0;
3917 table.style.paddingBottom = this.vDomBottomPad +
"px";
3918 this.vDomScrollPosBottom -= bottomRowHeight;
3921 bottomDiff = -(this.scrollTop - this.vDomScrollPosBottom);
3923 this._removeBottomRow(bottomDiff);
3927 RowManager.prototype._quickNormalizeRowHeight =
function (rows) {
3928 rows.forEach(
function (row) {
3932 rows.forEach(
function (row) {
3933 row.setCellHeight();
3940 RowManager.prototype.normalizeHeight =
function () {
3941 this.activeRows.forEach(
function (row) {
3942 row.normalizeHeight();
3947 RowManager.prototype.adjustTableSize =
function () {
3949 if (this.renderMode ===
"virtual") {
3950 this.height = this.element.clientHeight;
3951 this.vDomWindowBuffer = this.table.options.virtualDomBuffer || this.height;
3953 var otherHeight = this.columnManager.getElement().offsetHeight + (this.table.footerManager && !this.table.footerManager.external ? this.table.footerManager.getElement().offsetHeight : 0);
3955 this.element.style.minHeight =
"calc(100% - " + otherHeight +
"px)";
3956 this.element.style.height =
"calc(100% - " + otherHeight +
"px)";
3957 this.element.style.maxHeight =
"calc(100% - " + otherHeight +
"px)";
3962 RowManager.prototype.reinitialize =
function () {
3963 this.rows.forEach(
function (row) {
3969 RowManager.prototype.blockRedraw =
function () {
3970 this.redrawBlock =
true;
3971 this.redrawBlockRestoreConfig =
false;
3975 RowManager.prototype.restoreRedraw =
function () {
3976 this.redrawBlock =
false;
3978 if (this.redrawBlockRestoreConfig) {
3979 this.refreshActiveData(this.redrawBlockRestoreConfig.stage,
this.redrawBlockRestoreConfig.skipStage,
this.redrawBlockRestoreConfig.renderInPosition);
3981 this.redrawBlockRestoreConfig =
false;
3983 if (this.redrawBlockRederInPosition) {
3984 this.reRenderInPosition();
3988 this.redrawBlockRederInPosition =
false;
3992 RowManager.prototype.redraw =
function (force) {
3994 left = this.scrollLeft;
3996 this.adjustTableSize();
3998 this.table.tableWidth = this.table.element.clientWidth;
4001 if (this.renderMode ==
"classic") {
4003 if (this.table.options.groupBy) {
4004 this.refreshActiveData(
"group",
false,
false);
4006 this._simpleRender();
4009 this.reRenderInPosition();
4010 this.scrollHorizontal(left);
4013 if (!this.displayRowsCount) {
4014 if (this.table.options.placeholder) {
4015 this.getElement().appendChild(this.table.options.placeholder);
4023 RowManager.prototype.resetScroll =
function () {
4024 this.element.scrollLeft = 0;
4025 this.element.scrollTop = 0;
4027 if (this.table.browser ===
"ie") {
4028 var
event = document.createEvent(
"Event");
4029 event.initEvent(
"scroll",
false,
true);
4030 this.element.dispatchEvent(event);
4032 this.element.dispatchEvent(
new Event(
'scroll'));
4037 var RowComponent =
function RowComponent(row) {
4041 RowComponent.prototype.getData =
function (transform) {
4042 return this._row.getData(transform);
4045 RowComponent.prototype.getElement =
function () {
4046 return this._row.getElement();
4049 RowComponent.prototype.getCells =
function () {
4052 this._row.getCells().forEach(
function (cell) {
4053 cells.push(cell.getComponent());
4059 RowComponent.prototype.getCell =
function (column) {
4060 var cell = this._row.getCell(column);
4061 return cell ? cell.getComponent() :
false;
4064 RowComponent.prototype.getIndex =
function () {
4065 return this._row.getData(
"data")[this._row.table.options.index];
4068 RowComponent.prototype.getPosition =
function (active) {
4069 return this._row.table.rowManager.getRowPosition(this._row, active);
4072 RowComponent.prototype.delete =
function () {
4073 return this._row.delete();
4076 RowComponent.prototype.scrollTo =
function () {
4077 return this._row.table.rowManager.scrollToRow(this._row);
4080 RowComponent.prototype.pageTo =
function () {
4081 if (this._row.table.modExists(
"page",
true)) {
4082 return this._row.table.modules.page.setPageToRow(this._row);
4086 RowComponent.prototype.move =
function (to, after) {
4087 this._row.moveToRow(to, after);
4090 RowComponent.prototype.update =
function (data) {
4091 return this._row.updateData(data);
4094 RowComponent.prototype.normalizeHeight =
function () {
4095 this._row.normalizeHeight(
true);
4098 RowComponent.prototype.select =
function () {
4099 this._row.table.modules.selectRow.selectRows(this._row);
4102 RowComponent.prototype.deselect =
function () {
4103 this._row.table.modules.selectRow.deselectRows(this._row);
4106 RowComponent.prototype.toggleSelect =
function () {
4107 this._row.table.modules.selectRow.toggleRow(this._row);
4110 RowComponent.prototype.isSelected =
function () {
4111 return this._row.table.modules.selectRow.isRowSelected(this._row);
4114 RowComponent.prototype._getSelf =
function () {
4118 RowComponent.prototype.freeze =
function () {
4119 if (this._row.table.modExists(
"frozenRows",
true)) {
4120 this._row.table.modules.frozenRows.freezeRow(this._row);
4124 RowComponent.prototype.unfreeze =
function () {
4125 if (this._row.table.modExists(
"frozenRows",
true)) {
4126 this._row.table.modules.frozenRows.unfreezeRow(this._row);
4130 RowComponent.prototype.treeCollapse =
function () {
4131 if (this._row.table.modExists(
"dataTree",
true)) {
4132 this._row.table.modules.dataTree.collapseRow(this._row);
4136 RowComponent.prototype.treeExpand =
function () {
4137 if (this._row.table.modExists(
"dataTree",
true)) {
4138 this._row.table.modules.dataTree.expandRow(this._row);
4142 RowComponent.prototype.treeToggle =
function () {
4143 if (this._row.table.modExists(
"dataTree",
true)) {
4144 this._row.table.modules.dataTree.toggleRow(this._row);
4148 RowComponent.prototype.getTreeParent =
function () {
4149 if (this._row.table.modExists(
"dataTree",
true)) {
4150 return this._row.table.modules.dataTree.getTreeParent(this._row);
4156 RowComponent.prototype.getTreeChildren =
function () {
4157 if (this._row.table.modExists(
"dataTree",
true)) {
4158 return this._row.table.modules.dataTree.getTreeChildren(this._row);
4164 RowComponent.prototype.reformat =
function () {
4165 return this._row.reinitialize();
4168 RowComponent.prototype.getGroup =
function () {
4169 return this._row.getGroup().getComponent();
4172 RowComponent.prototype.getTable =
function () {
4173 return this._row.table;
4176 RowComponent.prototype.getNextRow =
function () {
4177 var row = this._row.nextRow();
4178 return row ? row.getComponent() : row;
4181 RowComponent.prototype.getPrevRow =
function () {
4182 var row = this._row.prevRow();
4183 return row ? row.getComponent() : row;
4186 var Row =
function Row(data, parent) {
4187 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
"row";
4189 this.table = parent.table;
4190 this.parent = parent;
4193 this.element = this.createElement();
4197 this.heightStyled =
"";
4198 this.manualHeight =
false;
4199 this.outerHeight = 0;
4200 this.initialized =
false;
4201 this.heightInitialized =
false;
4204 this.generateElement();
4207 Row.prototype.createElement =
function () {
4208 var el = document.createElement(
"div");
4210 el.classList.add(
"tabulator-row");
4211 el.setAttribute(
"role",
"row");
4216 Row.prototype.getElement =
function () {
4217 return this.element;
4220 Row.prototype.detachElement =
function () {
4221 if (this.element && this.element.parentNode) {
4222 this.element.parentNode.removeChild(this.element);
4226 Row.prototype.generateElement =
function () {
4233 if (
self.table.options.selectable !==
false &&
self.table.modExists(
"selectRow")) {
4234 self.table.modules.selectRow.initializeRow(
this);
4238 if (
self.table.options.movableRows !==
false &&
self.table.modExists(
"moveRow")) {
4239 self.table.modules.moveRow.initializeRow(
this);
4243 if (
self.table.options.dataTree !==
false &&
self.table.modExists(
"dataTree")) {
4244 self.table.modules.dataTree.initializeRow(
this);
4248 if (
self.table.options.responsiveLayout ===
"collapse" &&
self.table.modExists(
"responsiveLayout")) {
4249 self.table.modules.responsiveLayout.initializeRow(
this);
4253 if (
self.table.options.rowClick) {
4254 self.element.addEventListener(
"click",
function (e) {
4255 self.table.options.rowClick(e,
self.getComponent());
4259 if (
self.table.options.rowDblClick) {
4260 self.element.addEventListener(
"dblclick",
function (e) {
4261 self.table.options.rowDblClick(e,
self.getComponent());
4265 if (
self.table.options.rowContext) {
4266 self.element.addEventListener(
"contextmenu",
function (e) {
4267 self.table.options.rowContext(e,
self.getComponent());
4272 if (
self.table.options.rowMouseEnter) {
4273 self.element.addEventListener(
"mouseenter",
function (e) {
4274 self.table.options.rowMouseEnter(e,
self.getComponent());
4278 if (
self.table.options.rowMouseLeave) {
4279 self.element.addEventListener(
"mouseleave",
function (e) {
4280 self.table.options.rowMouseLeave(e,
self.getComponent());
4284 if (
self.table.options.rowMouseOver) {
4285 self.element.addEventListener(
"mouseover",
function (e) {
4286 self.table.options.rowMouseOver(e,
self.getComponent());
4290 if (
self.table.options.rowMouseOut) {
4291 self.element.addEventListener(
"mouseout",
function (e) {
4292 self.table.options.rowMouseOut(e,
self.getComponent());
4296 if (
self.table.options.rowMouseMove) {
4297 self.element.addEventListener(
"mousemove",
function (e) {
4298 self.table.options.rowMouseMove(e,
self.getComponent());
4302 if (
self.table.options.rowTap) {
4306 self.element.addEventListener(
"touchstart",
function (e) {
4308 }, { passive:
true });
4310 self.element.addEventListener(
"touchend",
function (e) {
4312 self.table.options.rowTap(e,
self.getComponent());
4319 if (
self.table.options.rowDblTap) {
4323 self.element.addEventListener(
"touchend",
function (e) {
4326 clearTimeout(dblTap);
4329 self.table.options.rowDblTap(e,
self.getComponent());
4332 dblTap = setTimeout(
function () {
4333 clearTimeout(dblTap);
4340 if (
self.table.options.rowTapHold) {
4344 self.element.addEventListener(
"touchstart",
function (e) {
4345 clearTimeout(tapHold);
4347 tapHold = setTimeout(
function () {
4348 clearTimeout(tapHold);
4351 self.table.options.rowTapHold(e,
self.getComponent());
4353 }, { passive:
true });
4355 self.element.addEventListener(
"touchend",
function (e) {
4356 clearTimeout(tapHold);
4362 Row.prototype.generateCells =
function () {
4363 this.cells = this.table.columnManager.generateCells(
this);
4367 Row.prototype.initialize =
function (force) {
4370 if (!
self.initialized || force) {
4374 while (
self.element.firstChild) {
4375 self.element.removeChild(
self.element.firstChild);
4377 if (this.table.modExists(
"frozenColumns")) {
4378 this.table.modules.frozenColumns.layoutRow(
this);
4381 this.generateCells();
4383 self.cells.forEach(
function (cell) {
4384 self.element.appendChild(cell.getElement());
4385 cell.cellRendered();
4389 self.normalizeHeight();
4393 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
4394 self.table.modules.dataTree.layoutRow(
this);
4398 if (
self.table.options.responsiveLayout ===
"collapse" &&
self.table.modExists(
"responsiveLayout")) {
4399 self.table.modules.responsiveLayout.layoutRow(
this);
4402 if (
self.table.options.rowFormatter) {
4403 self.table.options.rowFormatter(
self.getComponent());
4407 if (
self.table.options.resizableRows &&
self.table.modExists(
"resizeRows")) {
4408 self.table.modules.resizeRows.initializeRow(
self);
4411 self.initialized =
true;
4415 Row.prototype.reinitializeHeight =
function () {
4416 this.heightInitialized =
false;
4418 if (this.element.offsetParent !== null) {
4419 this.normalizeHeight(
true);
4423 Row.prototype.reinitialize =
function () {
4424 this.initialized =
false;
4425 this.heightInitialized =
false;
4427 if (!this.manualHeight) {
4429 this.heightStyled =
"";
4432 if (this.element.offsetParent !== null) {
4433 this.initialize(
true);
4438 Row.prototype.calcHeight =
function (force) {
4441 minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
4443 this.cells.forEach(
function (cell) {
4444 var height = cell.getHeight();
4445 if (height > maxHeight) {
4451 this.height = Math.max(maxHeight, minHeight);
4453 this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
4456 this.heightStyled = this.height ? this.height +
"px" :
"";
4457 this.outerHeight = this.element.offsetHeight;
4461 Row.prototype.setCellHeight =
function () {
4462 this.cells.forEach(
function (cell) {
4466 this.heightInitialized =
true;
4469 Row.prototype.clearCellHeight =
function () {
4470 this.cells.forEach(
function (cell) {
4476 Row.prototype.normalizeHeight =
function (force) {
4479 this.clearCellHeight();
4482 this.calcHeight(force);
4484 this.setCellHeight();
4494 Row.prototype.setHeight =
function (height, force) {
4495 if (this.height != height || force) {
4497 this.manualHeight =
true;
4499 this.height = height;
4500 this.heightStyled = height ? height +
"px" :
"";
4502 this.setCellHeight();
4505 this.outerHeight = this.element.offsetHeight;
4510 Row.prototype.getHeight =
function () {
4511 return this.outerHeight;
4515 Row.prototype.getWidth =
function () {
4516 return this.element.offsetWidth;
4521 Row.prototype.deleteCell =
function (cell) {
4522 var index = this.cells.indexOf(cell);
4525 this.cells.splice(index, 1);
4531 Row.prototype.setData =
function (data) {
4532 if (this.table.modExists(
"mutator")) {
4533 data = this.table.modules.mutator.transformRow(data,
"data", data);
4538 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {
4539 this.table.modules.reactiveData.watchRow(
this);
4544 Row.prototype.updateData =
function (data) {
4547 var visible = Tabulator.prototype.helpers.elVisible(this.element),
4550 return new Promise(
function (resolve, reject) {
4552 if (typeof data ===
"string") {
4553 data = JSON.parse(data);
4556 if (_this13.table.options.reactiveData && _this13.table.modExists(
"reactiveData",
true)) {
4557 _this13.table.modules.reactiveData.block();
4561 if (_this13.table.modExists(
"mutator")) {
4563 tempData = Object.assign(tempData, _this13.data);
4564 tempData = Object.assign(tempData, data);
4566 data = _this13.table.modules.mutator.transformRow(tempData,
"data", data);
4570 for (var attrname in data) {
4571 _this13.data[attrname] = data[attrname];
4574 if (_this13.table.options.reactiveData && _this13.table.modExists(
"reactiveData",
true)) {
4575 _this13.table.modules.reactiveData.unblock();
4579 for (var attrname in data) {
4581 var columns = _this13.table.columnManager.getColumnsByFieldRoot(attrname);
4583 columns.forEach(
function (column) {
4584 var cell = _this13.getCell(column.getField());
4587 var value = column.getFieldValue(data);
4588 if (cell.getValue() != value) {
4589 cell.setValueProcessData(value);
4592 cell.cellRendered();
4601 _this13.normalizeHeight();
4603 if (_this13.table.options.rowFormatter) {
4604 _this13.table.options.rowFormatter(_this13.getComponent());
4607 _this13.initialized =
false;
4609 _this13.heightStyled =
"";
4612 if (_this13.table.options.dataTree !==
false && _this13.table.modExists(
"dataTree") && _this13.table.modules.dataTree.redrawNeeded(data)) {
4613 _this13.table.modules.dataTree.initializeRow(_this13);
4614 _this13.table.modules.dataTree.layoutRow(_this13);
4615 _this13.table.rowManager.refreshActiveData(
"tree",
false,
true);
4620 _this13.table.options.rowUpdated.call(_this13.table, _this13.getComponent());
4626 Row.prototype.getData =
function (transform) {
4630 if (
self.table.modExists(
"accessor")) {
4631 return self.table.modules.accessor.transformRow(
self.data, transform);
4638 Row.prototype.getCell =
function (column) {
4641 column = this.table.columnManager.findColumn(column);
4643 match = this.cells.find(
function (cell) {
4644 return cell.column === column;
4650 Row.prototype.getCellIndex =
function (findCell) {
4651 return this.cells.findIndex(
function (cell) {
4652 return cell === findCell;
4656 Row.prototype.findNextEditableCell =
function (index) {
4657 var nextCell =
false;
4659 if (index < this.cells.length - 1) {
4660 for (var i = index + 1; i < this.cells.length; i++) {
4661 var cell = this.cells[i];
4663 if (cell.column.modules.edit && Tabulator.prototype.helpers.elVisible(cell.getElement())) {
4664 var allowEdit =
true;
4666 if (typeof cell.column.modules.edit.check ==
"function") {
4667 allowEdit = cell.column.modules.edit.check(cell.getComponent());
4681 Row.prototype.findPrevEditableCell =
function (index) {
4682 var prevCell =
false;
4685 for (var i = index - 1; i >= 0; i--) {
4686 var cell = this.cells[i],
4689 if (cell.column.modules.edit && Tabulator.prototype.helpers.elVisible(cell.getElement())) {
4690 if (typeof cell.column.modules.edit.check ==
"function") {
4691 allowEdit = cell.column.modules.edit.check(cell.getComponent());
4705 Row.prototype.getCells =
function () {
4709 Row.prototype.nextRow =
function () {
4710 var row = this.table.rowManager.nextDisplayRow(
this,
true);
4711 return row ||
false;
4714 Row.prototype.prevRow =
function () {
4715 var row = this.table.rowManager.prevDisplayRow(
this,
true);
4716 return row ||
false;
4719 Row.prototype.moveToRow =
function (to, before) {
4720 var toRow = this.table.rowManager.findRow(to);
4723 this.table.rowManager.moveRowActual(
this, toRow, !before);
4724 this.table.rowManager.refreshActiveData(
"display",
false,
true);
4726 console.warn(
"Move Error - No matching row found:", to);
4732 Row.prototype.delete =
function () {
4735 return new Promise(
function (resolve, reject) {
4738 if (_this14.table.options.history && _this14.table.modExists(
"history")) {
4740 if (_this14.table.options.groupBy && _this14.table.modExists(
"groupRows")) {
4741 rows = _this14.getGroup().rows;
4742 index = rows.indexOf(_this14);
4745 index = rows[index - 1];
4748 index = _this14.table.rowManager.getRowIndex(_this14);
4751 index = _this14.table.rowManager.rows[index - 1];
4755 _this14.table.modules.history.action(
"rowDelete", _this14, { data: _this14.getData(), pos: !index, index: index });
4758 _this14.deleteActual();
4764 Row.prototype.deleteActual =
function (blockRedraw) {
4765 var index = this.table.rowManager.getRowIndex(
this);
4768 if (this.table.modExists(
"selectRow")) {
4769 this.table.modules.selectRow._deselectRow(
this,
true);
4777 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData",
true)) {}
4782 if (this.modules.group) {
4783 this.modules.group.removeRow(
this);
4786 this.table.rowManager.deleteRow(
this, blockRedraw);
4790 this.initialized =
false;
4791 this.heightInitialized =
false;
4794 if (this.table.modExists(
"columnCalcs")) {
4795 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
4796 this.table.modules.columnCalcs.recalcRowGroup(
this);
4798 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
4803 Row.prototype.deleteCells =
function () {
4804 var cellCount = this.cells.length;
4806 for (var i = 0; i < cellCount; i++) {
4807 this.cells[0].delete();
4811 Row.prototype.wipe =
function () {
4814 while (this.element.firstChild) {
4815 this.element.removeChild(this.element.firstChild);
4816 }this.element =
false;
4819 if (this.element.parentNode) {
4820 this.element.parentNode.removeChild(this.element);
4824 Row.prototype.getGroup =
function () {
4825 return this.modules.group ||
false;
4829 Row.prototype.getComponent =
function () {
4830 return new RowComponent(
this);
4834 var CellComponent =
function CellComponent(cell) {
4838 CellComponent.prototype.getValue =
function () {
4839 return this._cell.getValue();
4842 CellComponent.prototype.getOldValue =
function () {
4843 return this._cell.getOldValue();
4846 CellComponent.prototype.getElement =
function () {
4847 return this._cell.getElement();
4850 CellComponent.prototype.getRow =
function () {
4851 return this._cell.row.getComponent();
4854 CellComponent.prototype.getData =
function () {
4855 return this._cell.row.getData();
4858 CellComponent.prototype.getField =
function () {
4859 return this._cell.column.getField();
4862 CellComponent.prototype.getColumn =
function () {
4863 return this._cell.column.getComponent();
4866 CellComponent.prototype.setValue =
function (value, mutate) {
4867 if (typeof mutate ==
"undefined") {
4871 this._cell.setValue(value, mutate);
4874 CellComponent.prototype.restoreOldValue =
function () {
4875 this._cell.setValueActual(this._cell.getOldValue());
4878 CellComponent.prototype.edit =
function (force) {
4879 return this._cell.edit(force);
4882 CellComponent.prototype.cancelEdit =
function () {
4883 this._cell.cancelEdit();
4886 CellComponent.prototype.nav =
function () {
4887 return this._cell.nav();
4890 CellComponent.prototype.checkHeight =
function () {
4891 this._cell.checkHeight();
4894 CellComponent.prototype.getTable =
function () {
4895 return this._cell.table;
4898 CellComponent.prototype._getSelf =
function () {
4902 var Cell =
function Cell(column, row) {
4904 this.table = column.table;
4905 this.column = column;
4907 this.element = null;
4909 this.oldValue = null;
4914 this.minWidth = null;
4922 Cell.prototype.build =
function () {
4923 this.generateElement();
4927 this._configureCell();
4929 this.setValueActual(this.column.getFieldValue(
this.row.data));
4932 Cell.prototype.generateElement =
function () {
4933 this.element = document.createElement(
'div');
4934 this.element.className =
"tabulator-cell";
4935 this.element.setAttribute(
"role",
"gridcell");
4936 this.element = this.element;
4939 Cell.prototype._configureCell =
function () {
4941 cellEvents =
self.column.cellEvents,
4942 element =
self.element,
4943 field = this.column.getField();
4946 element.style.textAlign =
self.column.hozAlign;
4949 element.setAttribute(
"tabulator-field", field);
4953 if (
self.column.definition.cssClass) {
4954 var classNames =
self.column.definition.cssClass.split(
" ");
4955 classNames.forEach(
function (className) {
4956 element.classList.add(className);
4961 if (this.table.options.tooltipGenerationMode ===
"hover") {
4962 element.addEventListener(
"mouseenter",
function (e) {
4963 self._generateTooltip();
4967 self._bindClickEvents(cellEvents);
4969 self._bindTouchEvents(cellEvents);
4971 self._bindMouseEvents(cellEvents);
4973 if (
self.column.modules.edit) {
4974 self.table.modules.edit.bindEditor(
self);
4977 if (
self.column.definition.rowHandle &&
self.table.options.movableRows !==
false &&
self.table.modExists(
"moveRow")) {
4978 self.table.modules.moveRow.initializeCell(
self);
4982 if (!
self.column.visible) {
4987 Cell.prototype._bindClickEvents =
function (cellEvents) {
4989 element =
self.element;
4992 if (cellEvents.cellClick ||
self.table.options.cellClick) {
4993 element.addEventListener(
"click",
function (e) {
4994 var component =
self.getComponent();
4996 if (cellEvents.cellClick) {
4997 cellEvents.cellClick.call(
self.table, e, component);
5000 if (
self.table.options.cellClick) {
5001 self.table.options.cellClick.call(
self.table, e, component);
5006 if (cellEvents.cellDblClick ||
this.table.options.cellDblClick) {
5007 element.addEventListener(
"dblclick",
function (e) {
5008 var component =
self.getComponent();
5010 if (cellEvents.cellDblClick) {
5011 cellEvents.cellDblClick.call(
self.table, e, component);
5014 if (
self.table.options.cellDblClick) {
5015 self.table.options.cellDblClick.call(
self.table, e, component);
5019 element.addEventListener(
"dblclick",
function (e) {
5023 if (document.selection) {
5025 var range = document.body.createTextRange();
5026 range.moveToElementText(
self.element);
5028 }
else if (window.getSelection) {
5029 var range = document.createRange();
5030 range.selectNode(
self.element);
5031 window.getSelection().removeAllRanges();
5032 window.getSelection().addRange(range);
5038 if (cellEvents.cellContext ||
this.table.options.cellContext) {
5039 element.addEventListener(
"contextmenu",
function (e) {
5040 var component =
self.getComponent();
5042 if (cellEvents.cellContext) {
5043 cellEvents.cellContext.call(
self.table, e, component);
5046 if (
self.table.options.cellContext) {
5047 self.table.options.cellContext.call(
self.table, e, component);
5053 Cell.prototype._bindMouseEvents =
function (cellEvents) {
5055 element =
self.element;
5057 if (cellEvents.cellMouseEnter ||
self.table.options.cellMouseEnter) {
5058 element.addEventListener(
"mouseenter",
function (e) {
5059 var component =
self.getComponent();
5061 if (cellEvents.cellMouseEnter) {
5062 cellEvents.cellMouseEnter.call(
self.table, e, component);
5065 if (
self.table.options.cellMouseEnter) {
5066 self.table.options.cellMouseEnter.call(
self.table, e, component);
5071 if (cellEvents.cellMouseLeave ||
self.table.options.cellMouseLeave) {
5072 element.addEventListener(
"mouseleave",
function (e) {
5073 var component =
self.getComponent();
5075 if (cellEvents.cellMouseLeave) {
5076 cellEvents.cellMouseLeave.call(
self.table, e, component);
5079 if (
self.table.options.cellMouseLeave) {
5080 self.table.options.cellMouseLeave.call(
self.table, e, component);
5085 if (cellEvents.cellMouseOver ||
self.table.options.cellMouseOver) {
5086 element.addEventListener(
"mouseover",
function (e) {
5087 var component =
self.getComponent();
5089 if (cellEvents.cellMouseOver) {
5090 cellEvents.cellMouseOver.call(
self.table, e, component);
5093 if (
self.table.options.cellMouseOver) {
5094 self.table.options.cellMouseOver.call(
self.table, e, component);
5099 if (cellEvents.cellMouseOut ||
self.table.options.cellMouseOut) {
5100 element.addEventListener(
"mouseout",
function (e) {
5101 var component =
self.getComponent();
5103 if (cellEvents.cellMouseOut) {
5104 cellEvents.cellMouseOut.call(
self.table, e, component);
5107 if (
self.table.options.cellMouseOut) {
5108 self.table.options.cellMouseOut.call(
self.table, e, component);
5113 if (cellEvents.cellMouseMove ||
self.table.options.cellMouseMove) {
5114 element.addEventListener(
"mousemove",
function (e) {
5115 var component =
self.getComponent();
5117 if (cellEvents.cellMouseMove) {
5118 cellEvents.cellMouseMove.call(
self.table, e, component);
5121 if (
self.table.options.cellMouseMove) {
5122 self.table.options.cellMouseMove.call(
self.table, e, component);
5128 Cell.prototype._bindTouchEvents =
function (cellEvents) {
5130 element =
self.element,
5135 if (cellEvents.cellTap ||
this.table.options.cellTap) {
5138 element.addEventListener(
"touchstart",
function (e) {
5140 }, { passive:
true });
5142 element.addEventListener(
"touchend",
function (e) {
5144 var component =
self.getComponent();
5146 if (cellEvents.cellTap) {
5147 cellEvents.cellTap.call(
self.table, e, component);
5150 if (
self.table.options.cellTap) {
5151 self.table.options.cellTap.call(
self.table, e, component);
5159 if (cellEvents.cellDblTap ||
this.table.options.cellDblTap) {
5162 element.addEventListener(
"touchend",
function (e) {
5165 clearTimeout(dblTap);
5168 var component =
self.getComponent();
5170 if (cellEvents.cellDblTap) {
5171 cellEvents.cellDblTap.call(
self.table, e, component);
5174 if (
self.table.options.cellDblTap) {
5175 self.table.options.cellDblTap.call(
self.table, e, component);
5179 dblTap = setTimeout(
function () {
5180 clearTimeout(dblTap);
5187 if (cellEvents.cellTapHold ||
this.table.options.cellTapHold) {
5190 element.addEventListener(
"touchstart",
function (e) {
5191 clearTimeout(tapHold);
5193 tapHold = setTimeout(
function () {
5194 clearTimeout(tapHold);
5197 var component =
self.getComponent();
5199 if (cellEvents.cellTapHold) {
5200 cellEvents.cellTapHold.call(
self.table, e, component);
5203 if (
self.table.options.cellTapHold) {
5204 self.table.options.cellTapHold.call(
self.table, e, component);
5207 }, { passive:
true });
5209 element.addEventListener(
"touchend",
function (e) {
5210 clearTimeout(tapHold);
5217 Cell.prototype._generateContents =
function () {
5220 if (this.table.modExists(
"format")) {
5221 val = this.table.modules.format.formatValue(
this);
5223 val = this.element.innerHTML = this.value;
5226 switch (typeof val ===
'undefined' ?
'undefined' : _typeof(val)) {
5228 if (val instanceof Node) {
5231 while (this.element.firstChild) {
5232 this.element.removeChild(this.element.firstChild);
5233 }this.element.appendChild(val);
5235 this.element.innerHTML =
"";
5238 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);
5244 this.element.innerHTML =
"";
5247 this.element.innerHTML = val;
5251 Cell.prototype.cellRendered =
function () {
5252 if (this.table.modExists(
"format") && this.table.modules.format.cellRendered) {
5253 this.table.modules.format.cellRendered(
this);
5258 Cell.prototype._generateTooltip =
function () {
5259 var tooltip = this.column.tooltip;
5262 if (tooltip ===
true) {
5263 tooltip = this.value;
5264 }
else if (typeof tooltip ==
"function") {
5265 tooltip = tooltip(this.getComponent());
5267 if (tooltip ===
false) {
5272 if (typeof tooltip ===
"undefined") {
5276 this.element.setAttribute(
"title", tooltip);
5278 this.element.setAttribute(
"title",
"");
5283 Cell.prototype.getElement =
function () {
5284 return this.element;
5287 Cell.prototype.getValue =
function () {
5291 Cell.prototype.getOldValue =
function () {
5292 return this.oldValue;
5297 Cell.prototype.setValue =
function (value, mutate) {
5299 var changed = this.setValueProcessData(value, mutate),
5303 if (this.table.options.history &&
this.table.modExists(
"history")) {
5304 this.table.modules.history.action(
"cellEdit",
this, { oldValue: this.oldValue, newValue: this.value });
5307 component = this.getComponent();
5309 if (this.column.cellEvents.cellEdited) {
5310 this.column.cellEvents.cellEdited.call(this.table, component);
5313 this.table.options.cellEdited.call(this.table, component);
5315 this.table.options.dataEdited.call(this.table, this.table.rowManager.getData());
5319 Cell.prototype.setValueProcessData =
function (value, mutate) {
5320 var changed =
false;
5322 if (this.value != value) {
5327 if (this.column.modules.mutate) {
5328 value = this.table.modules.mutator.transformCell(
this, value);
5333 this.setValueActual(value);
5335 if (changed && this.table.modExists(
"columnCalcs")) {
5336 if (this.column.definition.topCalc ||
this.column.definition.bottomCalc) {
5337 if (this.table.options.groupBy &&
this.table.modExists(
"groupRows")) {
5339 if (this.table.options.columnCalcs ==
"table" ||
this.table.options.columnCalcs ==
"both") {
5340 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
5343 if (this.table.options.columnCalcs !=
"table") {
5344 this.table.modules.columnCalcs.recalcRowGroup(this.row);
5347 this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);
5355 Cell.prototype.setValueActual =
function (value) {
5356 this.oldValue = this.value;
5360 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData")) {
5361 this.table.modules.reactiveData.block();
5364 this.column.setFieldValue(this.row.data, value);
5366 if (this.table.options.reactiveData &&
this.table.modExists(
"reactiveData")) {
5367 this.table.modules.reactiveData.unblock();
5370 this._generateContents();
5371 this._generateTooltip();
5374 if (this.table.options.resizableColumns &&
this.table.modExists(
"resizeColumns")) {
5375 this.table.modules.resizeColumns.initializeColumn(
"cell", this.column, this.element);
5379 if (this.table.modExists(
"frozenColumns")) {
5380 this.table.modules.frozenColumns.layoutElement(this.element, this.column);
5384 Cell.prototype.setWidth =
function () {
5385 this.width = this.column.width;
5386 this.element.style.width = this.column.widthStyled;
5389 Cell.prototype.clearWidth =
function () {
5391 this.element.style.width =
"";
5394 Cell.prototype.getWidth =
function () {
5395 return this.width || this.element.offsetWidth;
5398 Cell.prototype.setMinWidth =
function () {
5399 this.minWidth = this.column.minWidth;
5400 this.element.style.minWidth = this.column.minWidthStyled;
5403 Cell.prototype.checkHeight =
function () {
5405 this.row.reinitializeHeight();
5408 Cell.prototype.clearHeight =
function () {
5409 this.element.style.height =
"";
5413 Cell.prototype.setHeight =
function () {
5414 this.height = this.row.height;
5415 this.element.style.height = this.row.heightStyled;
5418 Cell.prototype.getHeight =
function () {
5419 return this.height || this.element.offsetHeight;
5422 Cell.prototype.show =
function () {
5423 this.element.style.display =
"";
5426 Cell.prototype.hide =
function () {
5427 this.element.style.display =
"none";
5430 Cell.prototype.edit =
function (force) {
5431 if (this.table.modExists(
"edit",
true)) {
5432 return this.table.modules.edit.editCell(
this, force);
5436 Cell.prototype.cancelEdit =
function () {
5437 if (this.table.modExists(
"edit",
true)) {
5438 var editing = this.table.modules.edit.getCurrentCell();
5440 if (editing && editing._getSelf() ===
this) {
5441 this.table.modules.edit.cancelEdit();
5443 console.warn(
"Cancel Editor Error - This cell is not currently being edited ");
5448 Cell.prototype.delete =
function () {
5449 if (!this.table.rowManager.redrawBlock) {
5450 this.element.parentNode.removeChild(this.element);
5452 this.element =
false;
5453 this.column.deleteCell(
this);
5454 this.row.deleteCell(
this);
5460 Cell.prototype.nav =
function () {
5464 index = this.row.getCellIndex(
this);
5467 next:
function next() {
5468 var nextCell = this.right(),
5472 nextRow =
self.table.rowManager.nextDisplayRow(
self.row,
true);
5475 nextCell = nextRow.findNextEditableCell(-1);
5488 prev:
function prev() {
5489 var nextCell = this.left(),
5493 prevRow =
self.table.rowManager.prevDisplayRow(
self.row,
true);
5496 nextCell = prevRow.findPrevEditableCell(prevRow.cells.length);
5509 left:
function left() {
5511 nextCell =
self.row.findPrevEditableCell(index);
5520 right:
function right() {
5521 nextCell =
self.row.findNextEditableCell(index);
5531 var nextRow =
self.table.rowManager.prevDisplayRow(
self.row,
true);
5534 nextRow.cells[index].edit();
5537 down:
function down() {
5538 var nextRow =
self.table.rowManager.nextDisplayRow(
self.row,
true);
5541 nextRow.cells[index].edit();
5548 Cell.prototype.getIndex =
function () {
5549 this.row.getCellIndex(
this);
5553 Cell.prototype.getComponent =
function () {
5554 return new CellComponent(
this);
5556 var FooterManager =
function FooterManager(table) {
5558 this.active =
false;
5559 this.element = this.createElement();
5560 this.external =
false;
5566 FooterManager.prototype.createElement =
function () {
5567 var el = document.createElement(
"div");
5569 el.classList.add(
"tabulator-footer");
5574 FooterManager.prototype._initialize =
function (element) {
5575 if (this.table.options.footerElement) {
5577 switch (_typeof(this.table.options.footerElement)) {
5580 if (this.table.options.footerElement[0] ===
"<") {
5581 this.element.innerHTML = this.table.options.footerElement;
5583 this.external =
true;
5584 this.element = document.querySelector(this.table.options.footerElement);
5588 this.element = this.table.options.footerElement;
5594 FooterManager.prototype.getElement =
function () {
5595 return this.element;
5598 FooterManager.prototype.append =
function (element, parent) {
5599 this.activate(parent);
5601 this.element.appendChild(element);
5602 this.table.rowManager.adjustTableSize();
5605 FooterManager.prototype.prepend =
function (element, parent) {
5606 this.activate(parent);
5608 this.element.insertBefore(element, this.element.firstChild);
5609 this.table.rowManager.adjustTableSize();
5612 FooterManager.prototype.remove =
function (element) {
5613 element.parentNode.removeChild(element);
5617 FooterManager.prototype.deactivate =
function (force) {
5618 if (!this.element.firstChild || force) {
5619 if (!this.external) {
5620 this.element.parentNode.removeChild(this.element);
5622 this.active =
false;
5628 FooterManager.prototype.activate =
function (parent) {
5631 if (!this.external) {
5632 this.table.element.appendChild(this.getElement());
5633 this.table.element.style.display =
'';
5638 this.links.push(parent);
5642 FooterManager.prototype.redraw =
function () {
5643 this.links.forEach(
function (link) {
5644 link.footerRedraw();
5648 var Tabulator =
function Tabulator(element, options) {
5652 this.columnManager = null;
5653 this.rowManager = null;
5654 this.footerManager = null;
5656 this.browserSlow =
false;
5657 this.browserMobile =
false;
5661 this.initializeElement(element);
5662 this.initializeOptions(options || {});
5665 Tabulator.prototype.comms.register(
this);
5669 Tabulator.prototype.defaultOptions = {
5674 layoutColumnsOnNewData:
false,
5677 columnHeaderVertAlign:
"top",
5678 columnVertAlign:
false,
5680 resizableColumns:
true,
5681 resizableRows:
false,
5690 reactiveData:
false,
5692 nestedFieldSeparator:
".",
5695 tooltipsHeader:
false,
5696 tooltipGenerationMode:
"load",
5699 initialFilter:
false,
5700 initialHeaderFilter:
false,
5702 columnHeaderSortMulti:
true,
5704 sortOrderReverse:
false,
5707 headerSortTristate:
false,
5709 footerElement:
false,
5715 tabEndNewRow:
false,
5717 invalidOptionWarnings:
true,
5720 clipboardCopyStyled:
true,
5721 clipboardCopySelector:
"active",
5722 clipboardCopyFormatter:
"table",
5723 clipboardPasteParser:
"table",
5724 clipboardPasteAction:
"insert",
5725 clipboardCopyConfig:
false,
5727 clipboardCopied:
function clipboardCopied() {},
5728 clipboardPasted:
function clipboardPasted() {},
5729 clipboardPasteError:
function clipboardPasteError() {},
5731 downloadDataFormatter:
false,
5732 downloadReady:
function downloadReady(data, blob) {
5735 downloadComplete:
false,
5736 downloadConfig:
false,
5739 dataTreeElementColumn:
false,
5740 dataTreeBranchElement:
true,
5741 dataTreeChildIndent: 9,
5742 dataTreeChildField:
"_children",
5743 dataTreeCollapseElement:
false,
5744 dataTreeExpandElement:
false,
5745 dataTreeStartExpanded:
false,
5746 dataTreeRowExpanded:
function dataTreeRowExpanded() {},
5747 dataTreeRowCollapsed:
function dataTreeRowCollapsed() {},
5750 printFormatter:
false,
5753 printCopyStyle:
true,
5754 printVisibleRows:
true,
5757 addRowPos:
"bottom",
5759 selectable:
"highlight",
5760 selectableRangeMode:
"drag",
5761 selectableRollingSelection:
true,
5762 selectablePersistence:
true,
5763 selectableCheck:
function selectableCheck(data, row) {
5767 headerFilterPlaceholder:
false,
5769 headerVisible:
true,
5777 virtualDomBuffer: 0,
5779 persistentLayout:
false,
5780 persistentSort:
false,
5781 persistentFilter:
false,
5783 persistenceMode:
true,
5784 persistenceReaderFunc:
false,
5785 persistenceWriterFunc:
false,
5789 responsiveLayout:
false,
5790 responsiveLayoutCollapseStartOpen:
true,
5791 responsiveLayoutCollapseUseFormatters:
true,
5792 responsiveLayoutCollapseFormatter:
false,
5795 paginationSize:
false,
5796 paginationInitialPage: 1,
5797 paginationButtonCount: 5,
5798 paginationSizeSelector:
false,
5799 paginationElement:
false,
5800 paginationDataSent: {},
5801 paginationDataReceived: {},
5802 paginationAddRow:
"page",
5805 ajaxURLGenerator:
false,
5808 ajaxContentType:
"form",
5809 ajaxRequestFunc:
false,
5811 ajaxLoaderLoading:
false,
5812 ajaxLoaderError:
false,
5813 ajaxFiltering:
false,
5815 ajaxProgressiveLoad:
false,
5816 ajaxProgressiveLoadDelay: 0,
5817 ajaxProgressiveLoadScrollMargin: 0,
5820 groupStartOpen:
true,
5825 htmlOutputConfig:
false,
5827 movableColumns:
false,
5830 movableRowsConnectedTables:
false,
5831 movableRowsSender:
false,
5832 movableRowsReceiver:
"insert",
5833 movableRowsSendingStart:
function movableRowsSendingStart() {},
5834 movableRowsSent:
function movableRowsSent() {},
5835 movableRowsSentFailed:
function movableRowsSentFailed() {},
5836 movableRowsSendingStop:
function movableRowsSendingStop() {},
5837 movableRowsReceivingStart:
function movableRowsReceivingStart() {},
5838 movableRowsReceived:
function movableRowsReceived() {},
5839 movableRowsReceivedFailed:
function movableRowsReceivedFailed() {},
5840 movableRowsReceivingStop:
function movableRowsReceivingStop() {},
5842 scrollToRowPosition:
"top",
5843 scrollToRowIfVisible:
true,
5845 scrollToColumnPosition:
"left",
5846 scrollToColumnIfVisible:
true,
5848 rowFormatter:
false,
5853 tableBuilding:
function tableBuilding() {},
5854 tableBuilt:
function tableBuilt() {},
5857 renderStarted:
function renderStarted() {},
5858 renderComplete:
function renderComplete() {},
5867 rowMouseEnter:
false,
5868 rowMouseLeave:
false,
5869 rowMouseOver:
false,
5871 rowMouseMove:
false,
5872 rowAdded:
function rowAdded() {},
5873 rowDeleted:
function rowDeleted() {},
5874 rowMoved:
function rowMoved() {},
5875 rowUpdated:
function rowUpdated() {},
5876 rowSelectionChanged:
function rowSelectionChanged() {},
5877 rowSelected:
function rowSelected() {},
5878 rowDeselected:
function rowDeselected() {},
5879 rowResized:
function rowResized() {},
5884 cellDblClick:
false,
5889 cellMouseEnter:
false,
5890 cellMouseLeave:
false,
5891 cellMouseOver:
false,
5892 cellMouseOut:
false,
5893 cellMouseMove:
false,
5894 cellEditing:
function cellEditing() {},
5895 cellEdited:
function cellEdited() {},
5896 cellEditCancelled:
function cellEditCancelled() {},
5900 columnResized:
function columnResized() {},
5901 columnTitleChanged:
function columnTitleChanged() {},
5902 columnVisibilityChanged:
function columnVisibilityChanged() {},
5905 htmlImporting:
function htmlImporting() {},
5906 htmlImported:
function htmlImported() {},
5909 dataLoading:
function dataLoading() {},
5910 dataLoaded:
function dataLoaded() {},
5911 dataEdited:
function dataEdited() {},
5914 ajaxRequesting:
function ajaxRequesting() {},
5915 ajaxResponse:
false,
5916 ajaxError:
function ajaxError() {},
5919 dataFiltering:
false,
5920 dataFiltered:
false,
5923 dataSorting:
function dataSorting() {},
5924 dataSorted:
function dataSorted() {},
5927 groupToggleElement:
"arrow",
5928 groupClosedShowCalcs:
false,
5929 dataGrouping:
function dataGrouping() {},
5931 groupVisibilityChanged:
function groupVisibilityChanged() {},
5933 groupDblClick:
false,
5934 groupContext:
false,
5937 groupTapHold:
false,
5942 pageLoaded:
function pageLoaded() {},
5945 localized:
function localized() {},
5948 validationFailed:
function validationFailed() {},
5951 historyUndo:
function historyUndo() {},
5952 historyRedo:
function historyRedo() {},
5955 scrollHorizontal:
function scrollHorizontal() {},
5956 scrollVertical:
function scrollVertical() {}
5960 Tabulator.prototype.initializeOptions =
function (options) {
5963 if (options.invalidOptionWarnings !==
false) {
5964 for (var key in options) {
5965 if (typeof this.defaultOptions[key] ===
"undefined") {
5966 console.warn(
"Invalid table constructor option:", key);
5972 for (var key in this.defaultOptions) {
5973 if (key in options) {
5974 this.options[key] = options[key];
5976 if (Array.isArray(
this.defaultOptions[key])) {
5977 this.options[key] = [];
5978 }
else if (_typeof(this.defaultOptions[key]) ===
"object") {
5979 this.options[key] = {};
5981 this.options[key] = this.defaultOptions[key];
5987 Tabulator.prototype.initializeElement =
function (element) {
5989 if (typeof HTMLElement !==
"undefined" && element instanceof HTMLElement) {
5990 this.element = element;
5992 }
else if (typeof element ===
"string") {
5993 this.element = document.querySelector(element);
5998 console.error(
"Tabulator Creation Error - no element found matching selector: ", element);
6002 console.error(
"Tabulator Creation Error - Invalid element provided:", element);
6008 Tabulator.prototype._mapDepricatedFunctionality =
function () {
6011 if (this.options.persistentLayout ||
this.options.persistentSort ||
this.options.persistentFilter) {
6012 if (!this.options.persistence) {
6013 this.options.persistence = {};
6017 if (this.options.persistentLayout) {
6018 console.warn(
"persistentLayout option is deprecated, you should now use the persistence option");
6020 if (this.options.persistence !==
true && typeof
this.options.persistence.columns ===
"undefined") {
6021 this.options.persistence.columns =
true;
6025 if (this.options.persistentSort) {
6026 console.warn(
"persistentSort option is deprecated, you should now use the persistence option");
6028 if (this.options.persistence !==
true && typeof
this.options.persistence.sort ===
"undefined") {
6029 this.options.persistence.sort =
true;
6033 if (this.options.persistentFilter) {
6034 console.warn(
"persistentFilter option is deprecated, you should now use the persistence option");
6036 if (this.options.persistence !==
true && typeof
this.options.persistence.filter ===
"undefined") {
6037 this.options.persistence.filter =
true;
6041 if (this.options.columnVertAlign) {
6042 console.warn(
"columnVertAlign option is deprecated, you should now use the columnHeaderVertAlign option");
6044 this.options.columnHeaderVertAlign = this.options.columnVertAlign;
6048 Tabulator.prototype._clearSelection =
function () {
6050 this.element.classList.add(
"tabulator-block-select");
6052 if (window.getSelection) {
6053 if (window.getSelection().empty) {
6055 window.getSelection().empty();
6056 }
else if (window.getSelection().removeAllRanges) {
6058 window.getSelection().removeAllRanges();
6060 }
else if (document.selection) {
6062 document.selection.empty();
6065 this.element.classList.remove(
"tabulator-block-select");
6069 Tabulator.prototype._create =
function () {
6070 this._clearObjectPointers();
6072 this._mapDepricatedFunctionality();
6076 if (this.element.tagName ===
"TABLE") {
6077 if (this.modExists(
"htmlTableImport",
true)) {
6078 this.modules.htmlTableImport.parseTable();
6082 this.columnManager =
new ColumnManager(
this);
6083 this.rowManager =
new RowManager(
this);
6084 this.footerManager =
new FooterManager(
this);
6086 this.columnManager.setRowManager(this.rowManager);
6087 this.rowManager.setColumnManager(this.columnManager);
6089 this._buildElement();
6091 this._loadInitialData();
6095 Tabulator.prototype._clearObjectPointers =
function () {
6096 this.options.columns = this.options.columns.slice(0);
6098 if (!this.options.reactiveData) {
6099 this.options.data = this.options.data.slice(0);
6104 Tabulator.prototype._buildElement =
function () {
6107 var element = this.element,
6109 options = this.options;
6111 options.tableBuilding.call(
this);
6113 element.classList.add(
"tabulator");
6114 element.setAttribute(
"role",
"grid");
6117 while (element.firstChild) {
6118 element.removeChild(element.firstChild);
6120 if (options.height) {
6121 options.height = isNaN(options.height) ? options.height : options.height +
"px";
6122 element.style.height = options.height;
6125 this.columnManager.initialize();
6126 this.rowManager.initialize();
6128 this._detectBrowser();
6130 if (this.modExists(
"layout",
true)) {
6131 mod.layout.initialize(options.layout);
6135 if (options.headerFilterPlaceholder !==
false) {
6136 mod.localize.setHeaderFilterPlaceholder(options.headerFilterPlaceholder);
6139 for (var locale in options.langs) {
6140 mod.localize.installLang(locale, options.langs[locale]);
6143 mod.localize.setLocale(options.locale);
6146 if (typeof options.placeholder ==
"string") {
6148 var el = document.createElement(
"div");
6149 el.classList.add(
"tabulator-placeholder");
6151 var span = document.createElement(
"span");
6152 span.innerHTML = options.placeholder;
6154 el.appendChild(span);
6156 options.placeholder = el;
6160 element.appendChild(this.columnManager.getElement());
6161 element.appendChild(this.rowManager.getElement());
6163 if (options.footerElement) {
6164 this.footerManager.activate();
6167 if (options.persistence &&
this.modExists(
"persistence",
true)) {
6168 mod.persistence.initialize();
6171 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.columns) {
6172 options.columns = mod.persistence.load(
"columns", options.columns);
6175 if (options.movableRows &&
this.modExists(
"moveRow")) {
6176 mod.moveRow.initialize();
6179 if (options.autoColumns &&
this.options.data) {
6180 this.columnManager.generateColumnsFromRowData(this.options.data);
6183 if (this.modExists(
"columnCalcs")) {
6184 mod.columnCalcs.initialize();
6187 this.columnManager.setColumns(options.columns);
6189 if (options.dataTree &&
this.modExists(
"dataTree",
true)) {
6190 mod.dataTree.initialize();
6193 if (this.modExists(
"frozenRows")) {
6194 this.modules.frozenRows.initialize();
6197 if ((options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.sort || options.initialSort) && this.modExists(
"sort",
true)) {
6200 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.sort) {
6201 sorters = mod.persistence.load(
"sort");
6203 if (sorters ===
false && options.initialSort) {
6204 sorters = options.initialSort;
6206 }
else if (options.initialSort) {
6207 sorters = options.initialSort;
6210 mod.sort.setSort(sorters);
6213 if ((options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.filter || options.initialFilter) && this.modExists(
"filter",
true)) {
6216 if (options.persistence &&
this.modExists(
"persistence",
true) && mod.persistence.config.filter) {
6217 filters = mod.persistence.load(
"filter");
6219 if (filters ===
false && options.initialFilter) {
6220 filters = options.initialFilter;
6222 }
else if (options.initialFilter) {
6223 filters = options.initialFilter;
6226 mod.filter.setFilter(filters);
6229 if (options.initialHeaderFilter &&
this.modExists(
"filter",
true)) {
6230 options.initialHeaderFilter.forEach(
function (item) {
6232 var column = _this15.columnManager.findColumn(item.field);
6235 mod.filter.setHeaderFilterValue(column, item.value);
6237 console.warn(
"Column Filter Error - No matching column found:", item.field);
6243 if (this.modExists(
"ajax")) {
6244 mod.ajax.initialize();
6247 if (options.pagination &&
this.modExists(
"page",
true)) {
6248 mod.page.initialize();
6251 if (options.groupBy &&
this.modExists(
"groupRows",
true)) {
6252 mod.groupRows.initialize();
6255 if (this.modExists(
"keybindings")) {
6256 mod.keybindings.initialize();
6259 if (this.modExists(
"selectRow")) {
6260 mod.selectRow.clearSelectionData(
true);
6263 if (options.autoResize &&
this.modExists(
"resizeTable")) {
6264 mod.resizeTable.initialize();
6267 if (this.modExists(
"clipboard")) {
6268 mod.clipboard.initialize();
6271 if (options.printAsHtml &&
this.modExists(
"print")) {
6272 mod.print.initialize();
6275 options.tableBuilt.call(
this);
6278 Tabulator.prototype._loadInitialData =
function () {
6281 if (
self.options.pagination &&
self.modExists(
"page")) {
6282 self.modules.page.reset(
true);
6284 if (
self.options.pagination ==
"local") {
6285 if (
self.options.data.length) {
6286 self.rowManager.setData(
self.options.data);
6288 if ((
self.options.ajaxURL ||
self.options.ajaxURLGenerator) &&
self.modExists(
"ajax")) {
6289 self.modules.ajax.loadData().then(
function () {}).
catch(
function () {
6290 if (
self.options.paginationInitialPage) {
6291 self.modules.page.setPage(
self.options.paginationInitialPage);
6297 self.rowManager.setData(
self.options.data);
6301 if (
self.options.paginationInitialPage) {
6302 self.modules.page.setPage(
self.options.paginationInitialPage);
6305 if (
self.options.ajaxURL) {
6306 self.modules.page.setPage(
self.options.paginationInitialPage).then(
function () {}).
catch(
function () {});
6308 self.rowManager.setData([]);
6312 if (
self.options.data.length) {
6313 self.rowManager.setData(
self.options.data);
6315 if ((
self.options.ajaxURL ||
self.options.ajaxURLGenerator) &&
self.modExists(
"ajax")) {
6316 self.modules.ajax.loadData().then(
function () {}).
catch(
function () {});
6318 self.rowManager.setData(
self.options.data);
6325 Tabulator.prototype.destroy =
function () {
6326 var element = this.element;
6328 Tabulator.prototype.comms.deregister(
this);
6330 if (this.options.reactiveData &&
this.modExists(
"reactiveData",
true)) {
6331 this.modules.reactiveData.unwatchData();
6335 this.rowManager.rows.forEach(
function (row) {
6339 this.rowManager.rows = [];
6340 this.rowManager.activeRows = [];
6341 this.rowManager.displayRows = [];
6344 if (this.options.autoResize &&
this.modExists(
"resizeTable")) {
6345 this.modules.resizeTable.clearBindings();
6348 if (this.modExists(
"keybindings")) {
6349 this.modules.keybindings.clearBindings();
6353 while (element.firstChild) {
6354 element.removeChild(element.firstChild);
6355 }element.classList.remove(
"tabulator");
6358 Tabulator.prototype._detectBrowser =
function () {
6359 var ua = navigator.userAgent || navigator.vendor || window.opera;
6361 if (ua.indexOf(
"Trident") > -1) {
6362 this.browser =
"ie";
6363 this.browserSlow =
true;
6364 }
else if (ua.indexOf(
"Edge") > -1) {
6365 this.browser =
"edge";
6366 this.browserSlow =
true;
6367 }
else if (ua.indexOf(
"Firefox") > -1) {
6368 this.browser =
"firefox";
6369 this.browserSlow =
false;
6371 this.browser =
"other";
6372 this.browserSlow =
false;
6375 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));
6381 Tabulator.prototype.blockRedraw = function () {
6382 return this.rowManager.blockRedraw();
6386 Tabulator.prototype.restoreRedraw =
function () {
6387 return this.rowManager.restoreRedraw();
6391 Tabulator.prototype.setDataFromLocalFile =
function (extensions) {
6394 return new Promise(
function (resolve, reject) {
6395 var input = document.createElement(
"input");
6396 input.type =
"file";
6397 input.accept = extensions ||
".json,application/json";
6399 input.addEventListener(
"change",
function (e) {
6400 var file = input.files[0],
6401 reader =
new FileReader(),
6404 reader.readAsText(file);
6406 reader.onload =
function (e) {
6409 data = JSON.parse(reader.result);
6411 console.warn(
"File Load Error - File contents is invalid JSON", e);
6416 _this16._setData(data).then(
function (data) {
6418 }).
catch(
function (err) {
6423 reader.onerror =
function (e) {
6424 console.warn(
"File Load Error - Unable to read file");
6434 Tabulator.prototype.setData =
function (data, params, config) {
6435 if (this.modExists(
"ajax")) {
6436 this.modules.ajax.blockActiveRequest();
6439 return this._setData(data, params, config);
6442 Tabulator.prototype._setData =
function (data, params, config, inPosition) {
6445 if (typeof data ===
"string") {
6446 if (data.indexOf(
"{") == 0 || data.indexOf(
"[") == 0) {
6448 return self.rowManager.setData(JSON.parse(data), inPosition);
6451 if (
self.modExists(
"ajax",
true)) {
6453 self.modules.ajax.setParams(params);
6457 self.modules.ajax.setConfig(config);
6460 self.modules.ajax.setUrl(data);
6462 if (
self.options.pagination ==
"remote" &&
self.modExists(
"page",
true)) {
6463 self.modules.page.reset(
true);
6464 return self.modules.page.setPage(1);
6467 return self.modules.ajax.loadData(inPosition);
6474 return self.rowManager.setData(data, inPosition);
6478 if (
self.modExists(
"ajax") && (
self.modules.ajax.getUrl ||
self.options.ajaxURLGenerator)) {
6480 if (
self.options.pagination ==
"remote" &&
self.modExists(
"page",
true)) {
6481 self.modules.page.reset(
true);
6482 return self.modules.page.setPage(1);
6484 return self.modules.ajax.loadData(inPosition);
6488 return self.rowManager.setData([], inPosition);
6495 Tabulator.prototype.clearData =
function () {
6496 if (this.modExists(
"ajax")) {
6497 this.modules.ajax.blockActiveRequest();
6500 this.rowManager.clearData();
6504 Tabulator.prototype.getData =
function (active) {
6506 if (active ===
true) {
6507 console.warn(
"passing a boolean to the getData function is deprecated, you should now pass the string 'active'");
6511 return this.rowManager.getData(active);
6515 Tabulator.prototype.getDataCount =
function (active) {
6517 if (active ===
true) {
6518 console.warn(
"passing a boolean to the getDataCount function is deprecated, you should now pass the string 'active'");
6522 return this.rowManager.getDataCount(active);
6526 Tabulator.prototype.searchRows =
function (field, type, value) {
6527 if (this.modExists(
"filter",
true)) {
6528 return this.modules.filter.search(
"rows", field, type, value);
6533 Tabulator.prototype.searchData =
function (field, type, value) {
6534 if (this.modExists(
"filter",
true)) {
6535 return this.modules.filter.search(
"data", field, type, value);
6540 Tabulator.prototype.getHtml =
function (visible, style, config) {
6541 if (this.modExists(
"htmlTableExport",
true)) {
6542 return this.modules.htmlTableExport.getHtml(visible, style, config);
6547 Tabulator.prototype.print =
function (visible, style, config) {
6548 if (this.modExists(
"print",
true)) {
6549 return this.modules.print.printFullscreen(visible, style, config);
6554 Tabulator.prototype.getAjaxUrl =
function () {
6555 if (this.modExists(
"ajax",
true)) {
6556 return this.modules.ajax.getUrl();
6561 Tabulator.prototype.replaceData =
function (data, params, config) {
6562 if (this.modExists(
"ajax")) {
6563 this.modules.ajax.blockActiveRequest();
6566 return this._setData(data, params, config,
true);
6570 Tabulator.prototype.updateData =
function (data) {
6576 return new Promise(
function (resolve, reject) {
6577 if (_this17.modExists(
"ajax")) {
6578 _this17.modules.ajax.blockActiveRequest();
6581 if (typeof data ===
"string") {
6582 data = JSON.parse(data);
6586 data.forEach(
function (item) {
6587 var row =
self.rowManager.findRow(item[
self.options.index]);
6592 row.updateData(item).then(
function () {
6602 console.warn(
"Update Error - No data provided");
6603 reject(
"Update Error - No data provided");
6608 Tabulator.prototype.addData =
function (data, pos, index) {
6611 return new Promise(
function (resolve, reject) {
6612 if (_this18.modExists(
"ajax")) {
6613 _this18.modules.ajax.blockActiveRequest();
6616 if (typeof data ===
"string") {
6617 data = JSON.parse(data);
6621 _this18.rowManager.addRows(data, pos, index).then(
function (rows) {
6624 rows.forEach(
function (row) {
6625 output.push(row.getComponent());
6631 console.warn(
"Update Error - No data provided");
6632 reject(
"Update Error - No data provided");
6638 Tabulator.prototype.updateOrAddData =
function (data) {
6645 return new Promise(
function (resolve, reject) {
6646 if (_this19.modExists(
"ajax")) {
6647 _this19.modules.ajax.blockActiveRequest();
6650 if (typeof data ===
"string") {
6651 data = JSON.parse(data);
6655 data.forEach(
function (item) {
6656 var row =
self.rowManager.findRow(item[
self.options.index]);
6661 row.updateData(item).then(
function () {
6663 rows.push(row.getComponent());
6670 self.rowManager.addRows(item).then(
function (newRows) {
6672 rows.push(newRows[0].getComponent());
6681 console.warn(
"Update Error - No data provided");
6682 reject(
"Update Error - No data provided");
6688 Tabulator.prototype.getRow =
function (index) {
6689 var row = this.rowManager.findRow(index);
6692 return row.getComponent();
6694 console.warn(
"Find Error - No matching row found:", index);
6700 Tabulator.prototype.getRowFromPosition =
function (position, active) {
6701 var row = this.rowManager.getRowFromPosition(position, active);
6704 return row.getComponent();
6706 console.warn(
"Find Error - No matching row found:", position);
6712 Tabulator.prototype.deleteRow =
function (index) {
6715 return new Promise(
function (resolve, reject) {
6720 function doneCheck() {
6723 if (count == index.length) {
6725 self.rowManager.reRenderInPosition();
6731 if (!Array.isArray(index)) {
6735 index.forEach(
function (item) {
6736 var row = _this20.rowManager.findRow(item,
true);
6739 row.delete().then(
function () {
6742 }).
catch(
function (err) {
6747 console.warn(
"Delete Error - No matching row found:", item);
6748 reject(
"Delete Error - No matching row found");
6756 Tabulator.prototype.addRow =
function (data, pos, index) {
6759 return new Promise(
function (resolve, reject) {
6760 if (typeof data ===
"string") {
6761 data = JSON.parse(data);
6764 _this21.rowManager.addRows(data, pos, index).then(
function (rows) {
6766 if (_this21.modExists(
"columnCalcs")) {
6767 _this21.modules.columnCalcs.recalc(_this21.rowManager.activeRows);
6770 resolve(rows[0].getComponent());
6776 Tabulator.prototype.updateOrAddRow =
function (index, data) {
6779 return new Promise(
function (resolve, reject) {
6780 var row = _this22.rowManager.findRow(index);
6782 if (typeof data ===
"string") {
6783 data = JSON.parse(data);
6787 row.updateData(data).then(
function () {
6789 if (_this22.modExists(
"columnCalcs")) {
6790 _this22.modules.columnCalcs.recalc(_this22.rowManager.activeRows);
6793 resolve(row.getComponent());
6794 }).
catch(
function (err) {
6798 row = _this22.rowManager.addRows(data).then(
function (rows) {
6800 if (_this22.modExists(
"columnCalcs")) {
6801 _this22.modules.columnCalcs.recalc(_this22.rowManager.activeRows);
6804 resolve(rows[0].getComponent());
6805 }).
catch(
function (err) {
6813 Tabulator.prototype.updateRow =
function (index, data) {
6816 return new Promise(
function (resolve, reject) {
6817 var row = _this23.rowManager.findRow(index);
6819 if (typeof data ===
"string") {
6820 data = JSON.parse(data);
6824 row.updateData(data).then(
function () {
6825 resolve(row.getComponent());
6826 }).
catch(
function (err) {
6830 console.warn(
"Update Error - No matching row found:", index);
6831 reject(
"Update Error - No matching row found");
6837 Tabulator.prototype.scrollToRow =
function (index, position, ifVisible) {
6840 return new Promise(
function (resolve, reject) {
6841 var row = _this24.rowManager.findRow(index);
6844 _this24.rowManager.scrollToRow(row, position, ifVisible).then(
function () {
6846 }).
catch(
function (err) {
6850 console.warn(
"Scroll Error - No matching row found:", index);
6851 reject(
"Scroll Error - No matching row found");
6856 Tabulator.prototype.moveRow =
function (from, to, after) {
6857 var fromRow = this.rowManager.findRow(from);
6860 fromRow.moveToRow(to, after);
6862 console.warn(
"Move Error - No matching row found:", from);
6866 Tabulator.prototype.getRows =
function (active) {
6868 if (active ===
true) {
6869 console.warn(
"passing a boolean to the getRows function is deprecated, you should now pass the string 'active'");
6873 return this.rowManager.getComponents(active);
6877 Tabulator.prototype.getRowPosition =
function (index, active) {
6878 var row = this.rowManager.findRow(index);
6881 return this.rowManager.getRowPosition(row, active);
6883 console.warn(
"Position Error - No matching row found:", index);
6889 Tabulator.prototype.copyToClipboard =
function (selector, selectorParams, formatter, formatterParams) {
6890 if (this.modExists(
"clipboard",
true)) {
6891 this.modules.clipboard.copy(selector, selectorParams, formatter, formatterParams);
6897 Tabulator.prototype.setColumns =
function (definition) {
6898 this.columnManager.setColumns(definition);
6901 Tabulator.prototype.getColumns =
function (structured) {
6902 return this.columnManager.getComponents(structured);
6905 Tabulator.prototype.getColumn =
function (field) {
6906 var col = this.columnManager.findColumn(field);
6909 return col.getComponent();
6911 console.warn(
"Find Error - No matching column found:", field);
6916 Tabulator.prototype.getColumnDefinitions =
function () {
6917 return this.columnManager.getDefinitionTree();
6920 Tabulator.prototype.getColumnLayout =
function () {
6921 if (this.modExists(
"persistence",
true)) {
6922 return this.modules.persistence.parseColumns(this.columnManager.getColumns());
6926 Tabulator.prototype.setColumnLayout =
function (layout) {
6927 if (this.modExists(
"persistence",
true)) {
6928 this.columnManager.setColumns(this.modules.persistence.mergeDefinition(
this.options.columns, layout));
6934 Tabulator.prototype.showColumn =
function (field) {
6935 var column = this.columnManager.findColumn(field);
6940 if (this.options.responsiveLayout &&
this.modExists(
"responsiveLayout",
true)) {
6941 this.modules.responsiveLayout.update();
6944 console.warn(
"Column Show Error - No matching column found:", field);
6949 Tabulator.prototype.hideColumn =
function (field) {
6950 var column = this.columnManager.findColumn(field);
6955 if (this.options.responsiveLayout &&
this.modExists(
"responsiveLayout",
true)) {
6956 this.modules.responsiveLayout.update();
6959 console.warn(
"Column Hide Error - No matching column found:", field);
6964 Tabulator.prototype.toggleColumn =
function (field) {
6965 var column = this.columnManager.findColumn(field);
6968 if (column.visible) {
6974 console.warn(
"Column Visibility Toggle Error - No matching column found:", field);
6979 Tabulator.prototype.addColumn =
function (definition, before, field) {
6982 return new Promise(
function (resolve, reject) {
6983 var column = _this25.columnManager.findColumn(field);
6985 _this25.columnManager.addColumn(definition, before, column).then(
function (column) {
6986 resolve(column.getComponent());
6987 }).
catch(
function (err) {
6993 Tabulator.prototype.deleteColumn =
function (field) {
6996 return new Promise(
function (resolve, reject) {
6997 var column = _this26.columnManager.findColumn(field);
7000 column.delete().then(
function () {
7002 }).
catch(
function (err) {
7006 console.warn(
"Column Delete Error - No matching column found:", field);
7012 Tabulator.prototype.updateColumnDefinition =
function (field, definition) {
7015 return new Promise(
function (resolve, reject) {
7016 var column = _this27.columnManager.findColumn(field);
7019 column.updateDefinition().then(
function (col) {
7021 }).
catch(
function (err) {
7025 console.warn(
"Column Update Error - No matching column found:", field);
7031 Tabulator.prototype.moveColumn =
function (from, to, after) {
7032 var fromColumn = this.columnManager.findColumn(from);
7033 var toColumn = this.columnManager.findColumn(to);
7037 this.columnManager.moveColumn(fromColumn, toColumn, after);
7039 console.warn(
"Move Error - No matching column found:", toColumn);
7042 console.warn(
"Move Error - No matching column found:", from);
7047 Tabulator.prototype.scrollToColumn =
function (field, position, ifVisible) {
7050 return new Promise(
function (resolve, reject) {
7051 var column = _this28.columnManager.findColumn(field);
7054 _this28.columnManager.scrollToColumn(column, position, ifVisible).then(
function () {
7056 }).
catch(
function (err) {
7060 console.warn(
"Scroll Error - No matching column found:", field);
7061 reject(
"Scroll Error - No matching column found");
7067 Tabulator.prototype.setLocale =
function (locale) {
7068 this.modules.localize.setLocale(locale);
7071 Tabulator.prototype.getLocale =
function () {
7072 return this.modules.localize.getLocale();
7075 Tabulator.prototype.getLang =
function (locale) {
7076 return this.modules.localize.getLang(locale);
7082 Tabulator.prototype.redraw =
function (force) {
7083 this.columnManager.redraw(force);
7084 this.rowManager.redraw(force);
7087 Tabulator.prototype.setHeight =
function (height) {
7089 if (this.rowManager.renderMode !==
"classic") {
7090 this.options.height = isNaN(height) ? height : height +
"px";
7091 this.element.style.height = this.options.height;
7092 this.rowManager.redraw();
7094 console.warn(
"setHeight function is not available in classic render mode");
7101 Tabulator.prototype.setSort =
function (sortList, dir) {
7102 if (this.modExists(
"sort",
true)) {
7103 this.modules.sort.setSort(sortList, dir);
7104 this.rowManager.sorterRefresh();
7108 Tabulator.prototype.getSorters =
function () {
7109 if (this.modExists(
"sort",
true)) {
7110 return this.modules.sort.getSort();
7114 Tabulator.prototype.clearSort =
function () {
7115 if (this.modExists(
"sort",
true)) {
7116 this.modules.sort.clear();
7117 this.rowManager.sorterRefresh();
7124 Tabulator.prototype.setFilter =
function (field, type, value) {
7125 if (this.modExists(
"filter",
true)) {
7126 this.modules.filter.setFilter(field, type, value);
7127 this.rowManager.filterRefresh();
7132 Tabulator.prototype.addFilter =
function (field, type, value) {
7133 if (this.modExists(
"filter",
true)) {
7134 this.modules.filter.addFilter(field, type, value);
7135 this.rowManager.filterRefresh();
7140 Tabulator.prototype.getFilters =
function (all) {
7141 if (this.modExists(
"filter",
true)) {
7142 return this.modules.filter.getFilters(all);
7146 Tabulator.prototype.setHeaderFilterFocus =
function (field) {
7147 if (this.modExists(
"filter",
true)) {
7148 var column = this.columnManager.findColumn(field);
7151 this.modules.filter.setHeaderFilterFocus(column);
7153 console.warn(
"Column Filter Focus Error - No matching column found:", field);
7159 Tabulator.prototype.setHeaderFilterValue =
function (field, value) {
7160 if (this.modExists(
"filter",
true)) {
7161 var column = this.columnManager.findColumn(field);
7164 this.modules.filter.setHeaderFilterValue(column, value);
7166 console.warn(
"Column Filter Error - No matching column found:", field);
7172 Tabulator.prototype.getHeaderFilters =
function () {
7173 if (this.modExists(
"filter",
true)) {
7174 return this.modules.filter.getHeaderFilters();
7179 Tabulator.prototype.removeFilter =
function (field, type, value) {
7180 if (this.modExists(
"filter",
true)) {
7181 this.modules.filter.removeFilter(field, type, value);
7182 this.rowManager.filterRefresh();
7187 Tabulator.prototype.clearFilter =
function (all) {
7188 if (this.modExists(
"filter",
true)) {
7189 this.modules.filter.clearFilter(all);
7190 this.rowManager.filterRefresh();
7195 Tabulator.prototype.clearHeaderFilter =
function () {
7196 if (this.modExists(
"filter",
true)) {
7197 this.modules.filter.clearHeaderFilter();
7198 this.rowManager.filterRefresh();
7203 Tabulator.prototype.selectRow =
function (rows) {
7204 if (this.modExists(
"selectRow",
true)) {
7205 if (rows ===
true) {
7206 console.warn(
"passing a boolean to the selectRowselectRow function is deprecated, you should now pass the string 'active'");
7209 this.modules.selectRow.selectRows(rows);
7213 Tabulator.prototype.deselectRow =
function (rows) {
7214 if (this.modExists(
"selectRow",
true)) {
7215 this.modules.selectRow.deselectRows(rows);
7219 Tabulator.prototype.toggleSelectRow =
function (row) {
7220 if (this.modExists(
"selectRow",
true)) {
7221 this.modules.selectRow.toggleRow(row);
7225 Tabulator.prototype.getSelectedRows =
function () {
7226 if (this.modExists(
"selectRow",
true)) {
7227 return this.modules.selectRow.getSelectedRows();
7231 Tabulator.prototype.getSelectedData =
function () {
7232 if (this.modExists(
"selectRow",
true)) {
7233 return this.modules.selectRow.getSelectedData();
7239 Tabulator.prototype.setMaxPage =
function (max) {
7240 if (this.options.pagination &&
this.modExists(
"page")) {
7241 this.modules.page.setMaxPage(max);
7247 Tabulator.prototype.setPage =
function (page) {
7248 if (this.options.pagination &&
this.modExists(
"page")) {
7249 return this.modules.page.setPage(page);
7251 return new Promise(
function (resolve, reject) {
7257 Tabulator.prototype.setPageToRow =
function (row) {
7260 return new Promise(
function (resolve, reject) {
7261 if (_this29.options.pagination && _this29.modExists(
"page")) {
7262 row = _this29.rowManager.findRow(row);
7265 _this29.modules.page.setPageToRow(row).then(
function () {
7267 }).
catch(
function () {
7279 Tabulator.prototype.setPageSize =
function (size) {
7280 if (this.options.pagination &&
this.modExists(
"page")) {
7281 this.modules.page.setPageSize(size);
7282 this.modules.page.setPage(1).then(
function () {}).
catch(
function () {});
7288 Tabulator.prototype.getPageSize =
function () {
7289 if (this.options.pagination &&
this.modExists(
"page",
true)) {
7290 return this.modules.page.getPageSize();
7294 Tabulator.prototype.previousPage =
function () {
7295 if (this.options.pagination &&
this.modExists(
"page")) {
7296 this.modules.page.previousPage();
7302 Tabulator.prototype.nextPage =
function () {
7303 if (this.options.pagination &&
this.modExists(
"page")) {
7304 this.modules.page.nextPage();
7310 Tabulator.prototype.getPage =
function () {
7311 if (this.options.pagination &&
this.modExists(
"page")) {
7312 return this.modules.page.getPage();
7318 Tabulator.prototype.getPageMax =
function () {
7319 if (this.options.pagination &&
this.modExists(
"page")) {
7320 return this.modules.page.getPageMax();
7328 Tabulator.prototype.setGroupBy =
function (groups) {
7329 if (this.modExists(
"groupRows",
true)) {
7330 this.options.groupBy = groups;
7331 this.modules.groupRows.initialize();
7332 this.rowManager.refreshActiveData(
"display");
7334 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
7335 this.modules.persistence.save(
"group");
7342 Tabulator.prototype.setGroupStartOpen =
function (values) {
7343 if (this.modExists(
"groupRows",
true)) {
7344 this.options.groupStartOpen = values;
7345 this.modules.groupRows.initialize();
7346 if (this.options.groupBy) {
7347 this.rowManager.refreshActiveData(
"group");
7349 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
7350 this.modules.persistence.save(
"group");
7353 console.warn(
"Grouping Update - cant refresh view, no groups have been set");
7360 Tabulator.prototype.setGroupHeader =
function (values) {
7361 if (this.modExists(
"groupRows",
true)) {
7362 this.options.groupHeader = values;
7363 this.modules.groupRows.initialize();
7364 if (this.options.groupBy) {
7365 this.rowManager.refreshActiveData(
"group");
7367 if (this.options.persistence &&
this.modExists(
"persistence",
true) && this.modules.persistence.config.group) {
7368 this.modules.persistence.save(
"group");
7371 console.warn(
"Grouping Update - cant refresh view, no groups have been set");
7378 Tabulator.prototype.getGroups =
function (values) {
7379 if (this.modExists(
"groupRows",
true)) {
7380 return this.modules.groupRows.getGroups(
true);
7387 Tabulator.prototype.getGroupedData =
function () {
7388 if (this.modExists(
"groupRows",
true)) {
7389 return this.options.groupBy ? this.modules.groupRows.getGroupedData() : this.getData();
7394 Tabulator.prototype.getCalcResults =
function () {
7395 if (this.modExists(
"columnCalcs",
true)) {
7396 return this.modules.columnCalcs.getResults();
7404 Tabulator.prototype.navigatePrev =
function () {
7407 if (this.modExists(
"edit",
true)) {
7408 cell = this.modules.edit.currentCell;
7411 return cell.nav().prev();
7418 Tabulator.prototype.navigateNext =
function () {
7421 if (this.modExists(
"edit",
true)) {
7422 cell = this.modules.edit.currentCell;
7425 return cell.nav().next();
7432 Tabulator.prototype.navigateLeft =
function () {
7435 if (this.modExists(
"edit",
true)) {
7436 cell = this.modules.edit.currentCell;
7440 return cell.nav().left();
7447 Tabulator.prototype.navigateRight =
function () {
7450 if (this.modExists(
"edit",
true)) {
7451 cell = this.modules.edit.currentCell;
7455 return cell.nav().right();
7462 Tabulator.prototype.navigateUp =
function () {
7465 if (this.modExists(
"edit",
true)) {
7466 cell = this.modules.edit.currentCell;
7470 return cell.nav().up();
7477 Tabulator.prototype.navigateDown =
function () {
7480 if (this.modExists(
"edit",
true)) {
7481 cell = this.modules.edit.currentCell;
7485 return cell.nav().down();
7493 Tabulator.prototype.undo =
function () {
7494 if (this.options.history &&
this.modExists(
"history",
true)) {
7495 return this.modules.history.undo();
7501 Tabulator.prototype.redo =
function () {
7502 if (this.options.history &&
this.modExists(
"history",
true)) {
7503 return this.modules.history.redo();
7509 Tabulator.prototype.getHistoryUndoSize =
function () {
7510 if (this.options.history &&
this.modExists(
"history",
true)) {
7511 return this.modules.history.getHistoryUndoSize();
7517 Tabulator.prototype.getHistoryRedoSize =
function () {
7518 if (this.options.history &&
this.modExists(
"history",
true)) {
7519 return this.modules.history.getHistoryRedoSize();
7527 Tabulator.prototype.download =
function (type, filename, options, active) {
7528 if (this.modExists(
"download",
true)) {
7529 this.modules.download.download(type, filename, options, active);
7533 Tabulator.prototype.downloadToTab =
function (type, filename, options, active) {
7534 if (this.modExists(
"download",
true)) {
7535 this.modules.download.download(type, filename, options, active,
true);
7541 Tabulator.prototype.tableComms =
function (table, module, action, data) {
7542 this.modules.comms.receive(table, module, action, data);
7548 Tabulator.prototype.moduleBindings = {};
7551 Tabulator.prototype.extendModule =
function (name, property, values) {
7553 if (Tabulator.prototype.moduleBindings[name]) {
7554 var source = Tabulator.prototype.moduleBindings[name].prototype[property];
7557 if ((typeof values ===
'undefined' ?
'undefined' : _typeof(values)) ==
"object") {
7558 for (var key in values) {
7559 source[key] = values[key];
7562 console.warn(
"Module Error - Invalid value type, it must be an object");
7565 console.warn(
"Module Error - property does not exist:", property);
7568 console.warn(
"Module Error - module does not exist:", name);
7573 Tabulator.prototype.registerModule =
function (name, module) {
7575 Tabulator.prototype.moduleBindings[name] = module;
7579 Tabulator.prototype.bindModules =
function () {
7582 for (var name in Tabulator.prototype.moduleBindings) {
7583 this.modules[name] =
new Tabulator.prototype.moduleBindings[name](
this);
7588 Tabulator.prototype.modExists =
function (plugin, required) {
7589 if (this.modules[plugin]) {
7593 console.error(
"Tabulator Module Not Installed: " + plugin);
7599 Tabulator.prototype.helpers = {
7601 elVisible:
function elVisible(el) {
7602 return !(el.offsetWidth <= 0 && el.offsetHeight <= 0);
7605 elOffset:
function elOffset(el) {
7606 var box = el.getBoundingClientRect();
7609 top: box.top + window.pageYOffset - document.documentElement.clientTop,
7610 left: box.left + window.pageXOffset - document.documentElement.clientLeft
7614 deepClone:
function deepClone(obj) {
7615 var clone = Array.isArray(obj) ? [] : {};
7617 for (var i in obj) {
7618 if (obj[i] != null && _typeof(obj[i]) ===
"object") {
7619 if (obj[i] instanceof Date) {
7620 clone[i] =
new Date(obj[i]);
7622 clone[i] = this.deepClone(obj[i]);
7632 Tabulator.prototype.comms = {
7634 register:
function register(table) {
7635 Tabulator.prototype.comms.tables.push(table);
7637 deregister:
function deregister(table) {
7638 var index = Tabulator.prototype.comms.tables.indexOf(table);
7641 Tabulator.prototype.comms.tables.splice(index, 1);
7644 lookupTable:
function lookupTable(query, silent) {
7649 if (typeof query ===
"string") {
7650 matches = document.querySelectorAll(query);
7652 if (matches.length) {
7653 for (var i = 0; i < matches.length; i++) {
7654 match = Tabulator.prototype.comms.matchElement(matches[i]);
7657 results.push(match);
7661 }
else if (typeof HTMLElement !==
"undefined" && query instanceof HTMLElement || query instanceof Tabulator) {
7662 match = Tabulator.prototype.comms.matchElement(query);
7665 results.push(match);
7667 }
else if (Array.isArray(query)) {
7668 query.forEach(
function (item) {
7669 results = results.concat(Tabulator.prototype.comms.lookupTable(item));
7673 console.warn(
"Table Connection Error - Invalid Selector", query);
7679 matchElement:
function matchElement(element) {
7680 return Tabulator.prototype.comms.tables.find(
function (table) {
7681 return element instanceof Tabulator ? table === element : table.element === element;
7686 Tabulator.prototype.findTable =
function (query) {
7687 var results = Tabulator.prototype.comms.lookupTable(query,
true);
7688 return Array.isArray(results) && !results.length ?
false : results;
7691 var Layout =
function Layout(table) {
7700 Layout.prototype.initialize =
function (layout) {
7702 if (this.modes[layout]) {
7707 console.warn(
"Layout Error - invalid mode set, defaulting to 'fitData' : " + layout);
7709 this.mode =
'fitData';
7712 this.table.element.setAttribute(
"tabulator-layout", this.mode);
7715 Layout.prototype.getMode =
function () {
7722 Layout.prototype.layout =
function () {
7724 this.modes[this.mode].call(
this, this.table.columnManager.columnsByIndex);
7729 Layout.prototype.modes = {
7733 "fitData":
function fitData(columns) {
7735 columns.forEach(
function (column) {
7737 column.reinitializeWidth();
7740 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
7742 this.table.modules.responsiveLayout.update();
7748 "fitDataFill":
function fitDataFill(columns) {
7750 columns.forEach(
function (column) {
7752 column.reinitializeWidth();
7755 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
7757 this.table.modules.responsiveLayout.update();
7763 "fitDataStretch":
function fitDataStretch(columns) {
7767 tableWidth = this.table.rowManager.element.clientWidth,
7771 columns.forEach(
function (column, i) {
7773 if (!column.widthFixed) {
7775 column.reinitializeWidth();
7778 if (_this30.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible) {
7783 if (column.visible) {
7785 colsWidth += column.getWidth();
7791 gap = tableWidth - colsWidth + lastCol.getWidth();
7793 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
7795 lastCol.setWidth(0);
7797 this.table.modules.responsiveLayout.update();
7802 lastCol.setWidth(gap);
7805 lastCol.reinitializeWidth();
7809 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
7811 this.table.modules.responsiveLayout.update();
7818 "fitColumns":
function fitColumns(columns) {
7822 var totalWidth =
self.table.element.clientWidth;
7828 var flexGrowUnits = 0;
7830 var flexColWidth = 0;
7832 var flexColumns = [];
7834 var fixedShrinkColumns = [];
7836 var flexShrinkUnits = 0;
7838 var overflowWidth = 0;
7843 function calcWidth(width) {
7847 if (typeof width ==
"string") {
7849 if (width.indexOf(
"%") > -1) {
7851 colWidth = totalWidth / 100 * parseInt(width);
7854 colWidth = parseInt(width);
7866 function scaleColumns(columns, freeSpace, colWidth, shrinkCols) {
7868 var oversizeCols = [],
7876 function calcGrow(col) {
7878 return colWidth * (col.column.definition.widthGrow || 1);
7881 function calcShrink(col) {
7883 return calcWidth(col.width) - colWidth * (col.column.definition.widthShrink || 0);
7886 columns.forEach(
function (col, i) {
7888 var width = shrinkCols ? calcShrink(col) : calcGrow(col);
7890 if (col.column.minWidth >= width) {
7892 oversizeCols.push(col);
7895 undersizeCols.push(col);
7897 changeUnits += shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1;
7901 if (oversizeCols.length) {
7903 oversizeCols.forEach(
function (col) {
7905 oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;
7907 col.width = col.column.minWidth;
7910 remainingSpace = freeSpace - oversizeSpace;
7912 nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace;
7914 gap = remainingSpace - nextColWidth * changeUnits;
7916 gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
7919 gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace;
7921 undersizeCols.forEach(
function (column) {
7923 column.width = shrinkCols ? calcShrink(column) : calcGrow(column);
7930 if (this.table.options.responsiveLayout &&
this.table.modExists(
"responsiveLayout",
true)) {
7932 this.table.modules.responsiveLayout.update();
7937 if (this.table.rowManager.element.scrollHeight >
this.table.rowManager.element.clientHeight) {
7939 totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;
7942 columns.forEach(
function (column) {
7944 var width, minWidth, colWidth;
7946 if (column.visible) {
7948 width = column.definition.width;
7950 minWidth = parseInt(column.minWidth);
7954 colWidth = calcWidth(width);
7956 fixedWidth += colWidth > minWidth ? colWidth : minWidth;
7958 if (column.definition.widthShrink) {
7960 fixedShrinkColumns.push({
7964 width: colWidth > minWidth ? colWidth : minWidth
7968 flexShrinkUnits += column.definition.widthShrink;
7980 flexGrowUnits += column.definition.widthGrow || 1;
7987 flexWidth = totalWidth - fixedWidth;
7991 flexColWidth = Math.floor(flexWidth / flexGrowUnits);
7995 var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth,
false);
7999 if (flexColumns.length && gapFill > 0) {
8001 flexColumns[flexColumns.length - 1].width += +gapFill;
8006 flexColumns.forEach(
function (col) {
8008 flexWidth -= col.width;
8011 overflowWidth = Math.abs(gapFill) + flexWidth;
8015 if (overflowWidth > 0 && flexShrinkUnits) {
8017 gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits),
true);
8022 if (fixedShrinkColumns.length) {
8024 fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill;
8027 flexColumns.forEach(
function (col) {
8029 col.column.setWidth(col.width);
8032 fixedShrinkColumns.forEach(
function (col) {
8034 col.column.setWidth(col.width);
8040 Tabulator.prototype.registerModule(
"layout", Layout);
8041 var Localize =
function Localize(table) {
8043 this.locale =
"default";
8049 Localize.prototype.setHeaderFilterPlaceholder =
function (placeholder) {
8050 this.langs.default.headerFilters.default = placeholder;
8054 Localize.prototype.setHeaderFilterColumnPlaceholder =
function (column, placeholder) {
8055 this.langs.default.headerFilters.columns[column] = placeholder;
8057 if (this.lang && !this.lang.headerFilters.columns[column]) {
8058 this.lang.headerFilters.columns[column] = placeholder;
8063 Localize.prototype.installLang =
function (locale, lang) {
8064 if (this.langs[locale]) {
8065 this._setLangProp(this.langs[locale], lang);
8067 this.langs[locale] = lang;
8071 Localize.prototype._setLangProp =
function (lang, values) {
8072 for (var key in values) {
8073 if (lang[key] && _typeof(lang[key]) ==
"object") {
8074 this._setLangProp(lang[key], values[key]);
8076 lang[key] = values[key];
8082 Localize.prototype.setLocale =
function (desiredLocale) {
8085 desiredLocale = desiredLocale ||
"default";
8088 function traverseLang(trans, path) {
8089 for (var prop in trans) {
8091 if (_typeof(trans[prop]) ==
"object") {
8095 traverseLang(trans[prop], path[prop]);
8097 path[prop] = trans[prop];
8103 if (desiredLocale ===
true && navigator.language) {
8105 desiredLocale = navigator.language.toLowerCase();
8108 if (desiredLocale) {
8111 if (!
self.langs[desiredLocale]) {
8112 var prefix = desiredLocale.split(
"-")[0];
8114 if (
self.langs[prefix]) {
8115 console.warn(
"Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix);
8116 desiredLocale = prefix;
8118 console.warn(
"Localization Error - Matching locale not found, using default: ", desiredLocale);
8119 desiredLocale =
"default";
8124 self.locale = desiredLocale;
8127 self.lang = Tabulator.prototype.helpers.deepClone(
self.langs.default || {});
8129 if (desiredLocale !=
"default") {
8130 traverseLang(
self.langs[desiredLocale],
self.lang);
8133 self.table.options.localized.call(
self.table,
self.locale,
self.lang);
8135 self._executeBindings();
8139 Localize.prototype.getLocale =
function (locale) {
8144 Localize.prototype.getLang =
function (locale) {
8145 return locale ? this.langs[locale] : this.lang;
8149 Localize.prototype.getText =
function (path, value) {
8150 var path = value ? path +
"|" + value : path,
8151 pathArray = path.split(
"|"),
8152 text = this._getLangElement(pathArray, this.locale);
8162 Localize.prototype._getLangElement =
function (path, locale) {
8164 var root =
self.lang;
8166 path.forEach(
function (level) {
8170 rootPath = root[level];
8172 if (typeof rootPath !=
"undefined") {
8184 Localize.prototype.bind =
function (path, callback) {
8185 if (!this.bindings[path]) {
8186 this.bindings[path] = [];
8189 this.bindings[path].push(callback);
8191 callback(this.getText(path), this.lang);
8195 Localize.prototype._executeBindings =
function () {
8198 var _loop =
function _loop(path) {
8199 self.bindings[path].forEach(
function (binding) {
8200 binding(
self.getText(path),
self.lang);
8204 for (var path in
self.bindings) {
8210 Localize.prototype.langs = {
8218 "loading":
"Loading",
8222 "page_size":
"Page Size",
8224 "first_title":
"First Page",
8226 "last_title":
"Last Page",
8228 "prev_title":
"Prev Page",
8230 "next_title":
"Next Page"
8233 "default":
"filter column...",
8239 Tabulator.prototype.registerModule(
"localize", Localize);
8240 var Comms =
function Comms(table) {
8244 Comms.prototype.getConnections =
function (selectors) {
8249 connection = Tabulator.prototype.comms.lookupTable(selectors);
8251 connection.forEach(
function (con) {
8252 if (
self.table !== con) {
8253 connections.push(con);
8260 Comms.prototype.send =
function (selectors, module, action, data) {
8262 connections = this.getConnections(selectors);
8264 connections.forEach(
function (connection) {
8265 connection.tableComms(
self.table.element, module, action, data);
8268 if (!connections.length && selectors) {
8269 console.warn(
"Table Connection Error - No tables matching selector found", selectors);
8273 Comms.prototype.receive =
function (table, module, action, data) {
8274 if (this.table.modExists(module)) {
8275 return this.table.modules[module].commsReceived(table, action, data);
8277 console.warn(
"Inter-table Comms Error - no such module:", module);
8281 Tabulator.prototype.registerModule(
"comms", Comms);