Skip to content

Commit 36fbf2d

Browse files
committed
feature update
1 parent 6579f84 commit 36fbf2d

File tree

4 files changed

+58
-16
lines changed

4 files changed

+58
-16
lines changed

docs/assets/sample-grid/grids-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const gridsConfig = {
1515
name: 'First Name',
1616
key: 'first_name',
1717
width: '150px',
18+
alwaysShow: true,
1819
filter: {},
1920
},
2021
{
@@ -23,7 +24,6 @@ const gridsConfig = {
2324
resizable: false,
2425
width: '150px',
2526
key: 'last_name',
26-
alwaysShow: true,
2727
filter: {},
2828
},
2929
{

src/grid-core.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class GridCoreComponent {
9595
9696
<div class="grid-comp-rows-loader"></div>
9797
<div class="grid-comp-no-rows">${this.i18n('no.rows')}</div>
98+
<div class="grid-comp-more-right-column-shadow"></div>
9899
<div class="grid-comp-col-resizing-line"></div>
99100
</div>
100101
@@ -253,6 +254,7 @@ export class GridCoreComponent {
253254
let classNames = 'grid-comp-col';
254255
let textContainerClassNames = 'grid-comp-col-text-container';
255256
let rightSection = '';
257+
let rightOutSection = '';
256258
let sortIcon = '';
257259
let resizable = colData.resizable;
258260
let sortable = colData.sortable;
@@ -279,7 +281,7 @@ export class GridCoreComponent {
279281

280282
if (colData.sticky) {
281283
classNames += ' grid-comp-col-sticky';
282-
rightSection += '<span class="grid-comp-col-sticky-shadow"></span>';
284+
rightOutSection += '<span class="grid-comp-col-sticky-shadow"></span>';
283285
}
284286

285287
if (resizable) {
@@ -306,6 +308,7 @@ export class GridCoreComponent {
306308
</div>
307309
${rightSection}
308310
</div>
311+
${rightOutSection}
309312
</th>`;
310313

311314
return html;
@@ -347,7 +350,7 @@ export class GridCoreComponent {
347350
let value = key ? rowData[colData.key] : '';
348351
let classNames = 'grid-comp-col';
349352
let textTooltip = this.getTooltipAttrText(value, true);
350-
let rightSection = '';
353+
let rightOutSection = '';
351354
let colStyle = {};
352355

353356
let colAttrData = {
@@ -374,7 +377,7 @@ export class GridCoreComponent {
374377

375378
if (colData.sticky) {
376379
classNames += ' grid-comp-col-sticky';
377-
rightSection += '<span class="grid-comp-col-sticky-shadow"></span>';
380+
rightOutSection += '<span class="grid-comp-col-sticky-shadow"></span>';
378381
}
379382

380383
if (colData.align) {
@@ -384,8 +387,8 @@ export class GridCoreComponent {
384387
html = `<td class="${classNames}" ${DomUtils.getAttributesText(colAttrData)}>
385388
<div class="grid-comp-col-content" ${DomUtils.getStyleText(colStyle)}>
386389
${html}
387-
${rightSection}
388390
</div>
391+
${rightOutSection}
389392
</td>`;
390393

391394
return html;
@@ -977,6 +980,8 @@ export class GridCoreComponent {
977980
this.addEvent(this.$pageNavPrev, 'click', 'onPageNavPrevClick');
978981
this.addEvent(this.$pageNavNext, 'click', 'onPageNavNextClick');
979982

983+
this.addEvent(this.$tableContainer, 'scroll', 'onTableContainerScroll');
984+
980985
if (this.showFilters) {
981986
this.addEvent(this.$filtersButton, 'click', 'onFiltersButtonClick');
982987
this.addEvent(this.$filtersBoxCancelButton, 'click', 'onFiltersBoxCancelButtonClick');
@@ -1156,6 +1161,10 @@ export class GridCoreComponent {
11561161
onExportButtonClick(e) {
11571162
this.exportRows(e.target);
11581163
}
1164+
1165+
onTableContainerScroll() {
1166+
this.setTableColumnShadow();
1167+
}
11591168
/** dom event methods - end */
11601169

11611170
/** before event methods - start */
@@ -1185,6 +1194,7 @@ export class GridCoreComponent {
11851194
this.renderFooter();
11861195
this.setVisibleColumns();
11871196
this.setBodyHeight();
1197+
this.setTableColumnShadow();
11881198

11891199
if (this.showFilters) {
11901200
this.renderFiltersBox();
@@ -1795,6 +1805,16 @@ export class GridCoreComponent {
17951805
reqData[`${d.key}[${d.criteria}]`] = d.value;
17961806
});
17971807
}
1808+
1809+
setTableColumnShadow() {
1810+
let $tableContainer = this.$tableContainer;
1811+
let scrollLeft = $tableContainer.scrollLeft;
1812+
let hasLeftColumn = scrollLeft > 0;
1813+
let hasRightColumn = $tableContainer.scrollWidth > $tableContainer.clientWidth + scrollLeft;
1814+
1815+
DomUtils.toggleClass(this.$wrapper, 'has-left-column', hasLeftColumn);
1816+
DomUtils.toggleClass(this.$wrapper, 'has-right-column', hasRightColumn);
1817+
}
17981818
/** set methods - end */
17991819

18001820
/** get methods - start */

src/sass/partials/grid.scss

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
margin-top: -#{$resizeButtonSize / 2};
6060
opacity: 0;
6161
cursor: col-resize;
62+
z-index: $minZIndex + 1;
6263
}
6364

6465
.grid-comp-table-wrapper {
@@ -87,12 +88,26 @@
8788
}
8889

8990
.grid-comp-col-sticky-shadow {
91+
display: none;
9092
position: absolute;
9193
top: 0;
92-
right: -#{$stickyColShadowWidth + $colPaddingRight};
93-
width: $stickyColShadowWidth;
94-
height: 100%;
95-
background: $stickyColShadowBg;
94+
right: 0;
95+
bottom: 0;
96+
width: 10px;
97+
box-shadow: $boxShadow7;
98+
pointer-events: none;
99+
}
100+
101+
.grid-comp-more-right-column-shadow {
102+
display: none;
103+
position: absolute;
104+
top: 0;
105+
right: 0;
106+
bottom: 0;
107+
width: 40px;
108+
z-index: $minZIndex + 6;
109+
background: $stickyColRightShadowBg;
110+
pointer-events: none;
96111
}
97112

98113
.grid-comp-col-content {
@@ -163,10 +178,6 @@
163178
.grid-comp-col-content {
164179
background-color: $rowHoverBg;
165180
}
166-
167-
.grid-comp-col-sticky-shadow {
168-
background: $stickyColShadowBgHover;
169-
}
170181
}
171182
}
172183
}
@@ -245,6 +256,18 @@
245256
}
246257
}
247258

259+
&.has-left-column {
260+
.grid-comp-col-sticky-shadow {
261+
display: block;
262+
}
263+
}
264+
265+
&.has-right-column {
266+
.grid-comp-more-right-column-shadow {
267+
display: block;
268+
}
269+
}
270+
248271
&.show-more-filters-tags {
249272
.grid-comp-filters-tags-more-button {
250273
.grid-comp-icon {

src/sass/partials/variable.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ $resizeButtonSize: $iconSize;
4242
$headerIconButtonSize: 36px;
4343
$minZIndex: 1;
4444

45-
$stickyColShadowWidth: 10px;
46-
$stickyColShadowBg: linear-gradient(to right, $primaryBg, transparent);
47-
$stickyColShadowBgHover: linear-gradient(to right, $rowHoverBg, transparent);
45+
$stickyColRightShadowBg: linear-gradient(to left, $primaryBg, transparent);
4846

4947
$boxShadow1: 0 -1px 7px 0 rgba(0, 0, 0, 0.07);
5048
$boxShadow2: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
5149
$boxShadow3: 0 -4px 8px 0 rgba(0, 0, 0, 0.2);
5250
$boxShadow4: inset 0px 11px 8px -10px rgba(0, 0, 0, 0.16);
5351
$boxShadow5: inset 0px -11px 7px -12px rgba(0, 0, 0, 0.16);
5452
$boxShadow6: 2px 2px 8px rgba(0, 0, 0, 0.22);
53+
$boxShadow7: 5px 0px 7px 0 rgba(0, 0, 0, 0.07);
5554

5655
$dropdownArrowWidth: 30px;
5756
$dropdownArrowSize: 8px;

0 commit comments

Comments
 (0)