`;
diff --git a/src/columnmanager.js b/src/columnmanager.js
index fabfbe72..83309944 100644
--- a/src/columnmanager.js
+++ b/src/columnmanager.js
@@ -166,6 +166,7 @@ export default class ColumnManager {
this.setColumnWidth(colIndex);
this.style.setBodyStyle();
$resizingCell = null;
+ this.bodyRenderer.setbodyWidth();
};
$.on(document.body, 'mouseup', onMouseup);
this.instance.on('onDestroy', () => {
@@ -270,6 +271,11 @@ export default class ColumnManager {
});
}
+ pinColumn(colIndex) {
+ this.instance.freeze();
+ this.instance.unfreeze();
+ }
+
removeColumn(colIndex) {
const removedCol = this.getColumn(colIndex);
this.instance.freeze();
diff --git a/src/datatable.js b/src/datatable.js
index b2655117..314fa4d6 100644
--- a/src/datatable.js
+++ b/src/datatable.js
@@ -110,9 +110,11 @@ class DataTable {
this.wrapper.innerHTML = `
@@ -127,6 +129,7 @@ class DataTable {
this.datatableWrapper = $('.datatable', this.wrapper);
this.header = $('.dt-header', this.wrapper);
+ this.bodyContainer = $('.dt-body', this.wrapper);
this.footer = $('.dt-footer', this.wrapper);
this.bodyScrollable = $('.dt-scrollable', this.wrapper);
this.freezeContainer = $('.dt-freeze', this.wrapper);
@@ -213,6 +216,10 @@ class DataTable {
this.columnmanager.sortColumn(colIndex, sortOrder);
}
+ pinColumn(colIndex) {
+ this.columnmanager.pinColumn(colIndex);
+ }
+
removeColumn(colIndex) {
this.columnmanager.removeColumn(colIndex);
}
diff --git a/src/defaults.js b/src/defaults.js
index 359f8e8a..8c453e9d 100644
--- a/src/defaults.js
+++ b/src/defaults.js
@@ -25,6 +25,12 @@ export default function getDefaultOptions(instance) {
this.sortColumn(column.colIndex, 'none');
}
},
+ // {
+ // label: instance.translate('Pin column'),
+ // action: function (column) {
+ // this.pinColumn(column.colIndex);
+ // }
+ // },
{
label: instance.translate('Remove column'),
action: function (column) {
diff --git a/src/style.css b/src/style.css
index 673ad6cc..e931924a 100644
--- a/src/style.css
+++ b/src/style.css
@@ -33,18 +33,28 @@
}
}
-.dt-header{
- border-bottom: 2px solid var(--dt-border-color);
+.dt-header {
+ top: 0;
}
-.datatable-content{
- .dt-header{
- display: flex;
- }
+.dt-header,
+.dt-footer {
+ position: sticky;
+ background: white;
+}
+
+.dt-footer {
+ bottom: 0;
+}
+.dt-body {
+ overflow-y: auto;
+ overflow-x: clip;
}
.dt-scrollable {
height: 40vw;
+ border-top: 2px solid var(--dt-border-color);
+ overflow-y: hidden;
&--highlight-all {
background-color: var(--dt-selection-highlight-color);
@@ -81,7 +91,7 @@
display: none;
}
- &:last-child:not(.dt-row-filter) {
+ &:last-child:not(.dt-row-filter) .dt-cell {
border-bottom: 1px solid var(--dt-border-color);
}
}
@@ -154,6 +164,7 @@
&--header {
background-color: var(--dt-header-cell-bg);
+ border-bottom: 2px solid var(--dt-border-color);
}
&--header:last-child {
@@ -309,9 +320,4 @@
body.dt-resize {
cursor: col-resize;
-}
-.dt-sticky-col {
- position: sticky;
- z-index: 1;
- left: 0;
}
\ No newline at end of file
diff --git a/src/style.js b/src/style.js
index 0ec37d80..a82681bc 100644
--- a/src/style.js
+++ b/src/style.js
@@ -23,7 +23,6 @@ export default class Style {
this.styleEl = styleEl;
this.bindResizeWindow();
- this.bindScrollHeader();
}
get stylesheet() {
@@ -39,66 +38,6 @@ export default class Style {
}
}
- bindScrollHeader() {
- this._settingHeaderPosition = false;
-
- $.on(this.bodyScrollable, 'scroll', (e) => {
-
- if (this._settingHeaderPosition) return;
-
- this._settingHeaderPosition = true;
-
- requestAnimationFrame(() => {
-
- const scrollLeft = e.target.scrollLeft;
-
- // Move non-sticky header and footer cells normally
- const nonStickyHeaderCells = this.header.querySelectorAll('.dt-cell:not(.dt-sticky-col)');
- const nonStickyFooterCells = this.footer.querySelectorAll('.dt-cell:not(.dt-sticky-col)');
-
- nonStickyHeaderCells.forEach(cell => {
- $.style(cell, { transform: `translateX(${-scrollLeft}px)` });
- });
-
- nonStickyFooterCells.forEach(cell => {
- $.style(cell, { transform: `translateX(${-scrollLeft}px)` });
- });
-
- const stickyHeaderCells = this.header.querySelectorAll(
- '.dt-cell.dt-sticky-col:not(.dt-cell-serial-no):not(.dt-cell-checkbox)'
- );
-
- stickyHeaderCells.forEach((headerCell) => {
-
- const colIndex = headerCell.getAttribute('data-col-index');
- const bodyCell = this.bodyScrollable.querySelector(`.dt-cell[data-col-index="${colIndex}"]`);
- const colLeft = parseFloat(headerCell.style.left) || 0; // get left position of the column
-
- // Find corresponding footer cell
- const footerCell = this.footer.querySelector(`.dt-cell[data-col-index="${colIndex}"]`);
-
- if (bodyCell && ~~(bodyCell.offsetLeft - scrollLeft) > colLeft) {
- headerCell.style.transform = `translateX(${-scrollLeft - 1}px)`;
- if (footerCell) {
- footerCell.style.transform = `translateX(${scrollLeft ? -scrollLeft - 1 : 0}px)`;
- }
- } else {
- headerCell.style.transform = `translateX(${colLeft - headerCell.offsetLeft}px)`;
- if (footerCell) footerCell.style.transform = `translateX(${colLeft - footerCell.offsetLeft}px)`;
- }
- });
-
- this._settingHeaderPosition = false;
- if (this.instance.noData) {
- $.style($('.no-data-message'), {
- left: `${this.instance.wrapper.clientWidth / 2 - (-scrollLeft)}px`
- });
- }
- this._settingHeaderPosition = false;
- });
- });
- }
-
onWindowResize() {
this.distributeRemainingWidth();
this.refreshColumnWidth();
diff --git a/src/translations/de.json b/src/translations/de.json
index 0e667df5..1a74b4c3 100644
--- a/src/translations/de.json
+++ b/src/translations/de.json
@@ -2,6 +2,7 @@
"Sort Ascending": "Aufsteigend sortieren",
"Sort Descending": "Absteigend sortieren",
"Reset sorting": "Sortierung zurücksetzen",
+ "Pin column": "Spalte anheften",
"Remove column": "Spalte entfernen",
"No Data": "Keine Daten",
"{count} cells copied": {
diff --git a/src/translations/en.json b/src/translations/en.json
index 80298682..16ac80a5 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -2,6 +2,7 @@
"Sort Ascending": "Sort Ascending",
"Sort Descending": "Sort Descending",
"Reset sorting": "Reset sorting",
+ "Pin column": "Pin column",
"Remove column": "Remove column",
"No Data": "No Data",
"{count} cells copied": {
diff --git a/src/translations/fr.json b/src/translations/fr.json
index 194ec108..80bd0f14 100644
--- a/src/translations/fr.json
+++ b/src/translations/fr.json
@@ -2,6 +2,7 @@
"Sort Ascending": "Trier par ordre croissant",
"Sort Descending": "Trier par ordre décroissant",
"Reset sorting": "Réinitialiser le tri",
+ "Pin column": "Épingler la colonne",
"Remove column": "Supprimer colonne",
"No Data": "Pas de données",
"{count} cells copied": {
diff --git a/src/translations/it.json b/src/translations/it.json
index a7308c15..1f19b41b 100644
--- a/src/translations/it.json
+++ b/src/translations/it.json
@@ -2,6 +2,7 @@
"Sort Ascending": "Ordinamento ascendente",
"Sort Descending": "Ordinamento decrescente",
"Reset sorting": "Azzeramento ordinamento",
+ "Pin column": "Colonna perno",
"Remove column": "Rimuovi colonna",
"No Data": "Nessun dato",
"{count} cells copied": {