Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

frozen_rows.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Tabulator v4.8.2 (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. this.detachRow(row);
  55. this.table.rowManager.adjustTableSize();
  56. this.table.rowManager.refreshActiveData("display");
  57. if (this.rows.length) {
  58. this.styleRows();
  59. }
  60. } else {
  61. console.warn("Freeze Error - Row is already unfrozen");
  62. }
  63. };
  64. FrozenRows.prototype.detachRow = function (row) {
  65. var index = this.rows.indexOf(row);
  66. if (index > -1) {
  67. var rowEl = row.getElement();
  68. rowEl.parentNode.removeChild(rowEl);
  69. this.rows.splice(index, 1);
  70. }
  71. };
  72. FrozenRows.prototype.styleRows = function (row) {
  73. var self = this;
  74. this.rows.forEach(function (row, i) {
  75. self.table.rowManager.styleRow(row, i);
  76. });
  77. };
  78. Tabulator.prototype.registerModule("frozenRows", FrozenRows);