From 9eb8fa12a6bfe1e493d91ff9593f18c5ada6b957 Mon Sep 17 00:00:00 2001 From: Azat Yamalov Date: Thu, 8 Dec 2022 11:42:35 +0300 Subject: [PATCH 1/6] footer --- pl-grid-column.js | 18 +++++-- pl-grid.js | 135 +++++++++++++++++++++++++++++++--------------- 2 files changed, 106 insertions(+), 47 deletions(-) diff --git a/pl-grid-column.js b/pl-grid-column.js index c5d08df..2ef3c61 100644 --- a/pl-grid-column.js +++ b/pl-grid-column.js @@ -65,6 +65,9 @@ class PlGridColumn extends PlElement { }, _cellTemplate: { type: Object + }, + _footerTemplate: { + type: Object } } @@ -142,11 +145,16 @@ class PlGridColumn extends PlElement { connectedCallback() { super.connectedCallback(); - let tplEl = [...this.childNodes].find(n => n.nodeType === document.COMMENT_NODE && n.textContent.startsWith('tpl:')); - if (tplEl) { - // host context can be assigned to template - this._cellTemplate = tplEl?._tpl; - this._cellTemplate._hctx = [...tplEl._hctx, this]; + let tplEls = [...this.childNodes].filter(n => n.nodeType === document.COMMENT_NODE && n.textContent.startsWith('tpl:')); + let footerTpl = tplEls.find(tplEl => tplEl._tpl.tpl.getAttribute('is') == 'footer'); + if(footerTpl) { + this._footerTemplate = footerTpl?._tpl; + this._footerTemplate._hctx = [...footerTpl._hctx, this]; + } + let cellTpl = tplEls.find(tplEl => !tplEl._tpl.tpl.hasAttribute('is')); + if(cellTpl) { + this._cellTemplate = cellTpl?._tpl; + this._cellTemplate._hctx = [...cellTpl._hctx, this]; } else { this._cellTemplate = html`[[_getValue(row, field, kind, format)]]`; diff --git a/pl-grid.js b/pl-grid.js index da682c1..b3b2035 100644 --- a/pl-grid.js +++ b/pl-grid.js @@ -40,9 +40,11 @@ class PlGrid extends PlResizeableMixin(PlElement) { #container { width: 100%; height: 100%; - overflow: auto; + display: flex; + flex-direction: column; position: relative; contain: strict; + overflow:auto; } #headerContainer{ @@ -50,30 +52,52 @@ class PlGrid extends PlResizeableMixin(PlElement) { width: 100%; position: sticky; background-color: var(--grey-lightest); - z-index: 1; + z-index: 2; top: 0; } + #footerContainer { + display: flex; + width: 100%; + background-color: var(--grey-lightest); + z-index: 2; + bottom: 0; + will-change: bottom; + height: 32px; + } + + #header{ display: var(--pl-grid-header-display, flex); - border-bottom: 1px solid var(--grey-light); + border-bottom: 1px solid var(--grey-base); position: sticky; top: 0; flex: 1; will-change: width; } + #footer{ + display: var(--pl-grid-header-display, flex); + border-top: 1px solid var(--grey-base); + position: sticky; + bottom: 0; + flex: 1; + will-change: width; + } + .headerEl[fixed], - .headerEl[action] { + .headerEl[action], + .footerEl[fixed], + .footerEl[action] { position: sticky; z-index: 3; } - .headerEl[action] { + .headerEl[action], .footerEl[action] { right: 0; } - .headerEl[hidden] { + .headerEl[hidden], .footerEl[hidden] { display: none; } @@ -146,8 +170,7 @@ class PlGrid extends PlResizeableMixin(PlElement) { .row[active]{ z-index: 1; - } - + } .top-toolbar ::slotted(*) { width: 100%; @@ -167,7 +190,8 @@ class PlGrid extends PlResizeableMixin(PlElement) { display: none; } `; - static treeFirstCellTemplate = html``; + static treeFirstCellTemplate = html``; static template = html`
@@ -176,7 +200,8 @@ class PlGrid extends PlResizeableMixin(PlElement) {