Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

frozen_rows.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Tabulator v4.6.3 (c) Oliver Folkerd */
  2. var FrozenRows = function FrozenRows(table) {
  3. this.table = table; //hold Tabulator object
  4. this.topElement = document.createElement("div");
  5. this.rows = [];
  6. this.displayIndex = 0; //index in display pipeline
  7. };
  8. FrozenRows.prototype.initialize = function () {
  9. this.rows = [];
  10. this.topElement.classList.add("tabulator-frozen-rows-holder");
  11. // this.table.columnManager.element.append(this.topElement);
  12. this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
  13. };
  14. FrozenRows.prototype.setDisplayIndex = function (index) {
  15. this.displayIndex = index;
  16. };
  17. FrozenRows.prototype.getDisplayIndex = function () {
  18. return this.displayIndex;
  19. };
  20. FrozenRows.prototype.isFrozen = function () {
  21. return !!this.rows.length;
  22. };
  23. //filter frozen rows out of display data
  24. FrozenRows.prototype.getRows = function (rows) {
  25. var self = this,
  26. frozen = [],
  27. output = rows.slice(0);
  28. this.rows.forEach(function (row) {
  29. var index = output.indexOf(row);
  30. if (index > -1) {
  31. output.splice(index, 1);
  32. }
  33. });
  34. return output;
  35. };
  36. FrozenRows.prototype.freezeRow = function (row) {
  37. if (!row.modules.frozen) {
  38. row.modules.frozen = true;
  39. this.topElement.appendChild(row.getElement());
  40. row.initialize();
  41. row.normalizeHeight();
  42. this.table.rowManager.adjustTableSize();
  43. this.rows.push(row);
  44. this.table.rowManager.refreshActiveData("display");
  45. this.styleRows();
  46. } else {
  47. console.warn("Freeze Error - Row is already frozen");
  48. }
  49. };
  50. FrozenRows.prototype.unfreezeRow = function (row) {
  51. var index = this.rows.indexOf(row);
  52. if (row.modules.frozen) {
  53. row.modules.frozen = false;
  54. var rowEl = row.getElement();
  55. rowEl.parentNode.removeChild(rowEl);
  56. this.table.rowManager.adjustTableSize();
  57. this.rows.splice(index, 1);
  58. this.table.rowManager.refreshActiveData("display");
  59. if (this.rows.length) {
  60. this.styleRows();
  61. }
  62. } else {
  63. console.warn("Freeze Error - Row is already unfrozen");
  64. }
  65. };
  66. FrozenRows.prototype.styleRows = function (row) {
  67. var self = this;
  68. this.rows.forEach(function (row, i) {
  69. self.table.rowManager.styleRow(row, i);
  70. });
  71. };
  72. Tabulator.prototype.registerModule("frozenRows", FrozenRows);