diff --git a/src/body-renderer.js b/src/body-renderer.js index 1176e3e..6c7b08a 100644 --- a/src/body-renderer.js +++ b/src/body-renderer.js @@ -123,6 +123,7 @@ export default class BodyRenderer { this.rowmanager.highlightCheckedRows(); this.cellmanager.selectAreaOnClusterChanged(); this.cellmanager.focusCellOnClusterChanged(); + this.bodyScrollable.style.removeProperty('overflow'); } showToastMessage(message, hideAfter) { diff --git a/src/cellmanager.js b/src/cellmanager.js index bf31217..5bde717 100644 --- a/src/cellmanager.js +++ b/src/cellmanager.js @@ -812,17 +812,13 @@ export default class CellManager { let sticky = false; - let checkboxserialNoclass = ''; - if (colIndex === 0 && this.options.checkboxColumn) { - if (cell.isHeader && !(cell.id in this.stickyColWitdh)) this.stickyRowWidth = 34; - checkboxserialNoclass = 'dt-cell-checkbox'; + if (cell.isHeader && !(cell.id in this.stickyColWitdh)) this.stickyRowWidth = 33; sticky = true; } else if (colIndex === serialNoColIndex && this.options.serialNoColumn) { if (cell.isHeader && !(cell.id in this.stickyColWitdh)) { this.stickyColWitdh[cell.id] = this.stickyRowWidth; - this.stickyRowWidth += (cell.width || 37); - checkboxserialNoclass = 'dt-cell-serial-no'; + this.stickyRowWidth += (cell.width || 32); } styles = `left:${this.stickyColWitdh[isBodyCell ? cell.column.id : cell.id]}px;`; sticky = true; @@ -830,12 +826,12 @@ export default class CellManager { } else if (cell.sticky) { if (cell.isHeader && !(cell.id in this.stickyColWitdh)) { this.stickyColWitdh[cell.id] = this.stickyRowWidth; - this.stickyRowWidth += ((cell.width || 100) + 1); + this.stickyRowWidth += (cell.width || 100); } styles = `left:${this.stickyColWitdh[cell.id]}px;`; sticky = true; - } else if ((isBodyCell || isTotalRow) && cell.column.sticky) { + } else if (isBodyCell && cell.column.sticky) { styles = `left:${this.stickyColWitdh[cell.column.id]}px;`; sticky = true; } @@ -849,8 +845,7 @@ export default class CellManager { isHeader ? `dt-cell--header-${colIndex}` : '', isFilter ? 'dt-cell--filter' : '', isBodyCell && (row && row.meta.isTreeNodeClose) ? 'dt-cell--tree-close' : '', - sticky ? 'dt-sticky-col' : '', - checkboxserialNoclass, + sticky ? 'dt-sticky-col' : '' ].join(' '); return ` diff --git a/src/style.css b/src/style.css index 451a151..a57da75 100644 --- a/src/style.css +++ b/src/style.css @@ -27,16 +27,14 @@ .datatable { position: relative; overflow: hidden; - .dt-cell--col-0{ - border-left: 1px solid var(--dt-border-color); - } } -.dt-header{ - border-bottom: 2px solid var(--dt-border-color); +.dt-scrollable > .dt-row-0{ + border-top: 2px solid var(--dt-border-color); } .datatable-content{ + overflow-x: auto; .dt-header{ display: flex; } @@ -80,7 +78,7 @@ .dt-cell { border: 1px solid var(--dt-border-color); border-bottom: none; - border-left: none; + border-right: none; position: relative; outline: none; padding: 0; diff --git a/src/style.js b/src/style.js index 051b75f..a82681b 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,60 +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.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; - }); - }); - } - onWindowResize() { this.distributeRemainingWidth(); this.refreshColumnWidth();