-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for hidden column issue fixes #981 #985
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1616,6 +1616,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
|
||
for (let i = 0; i < this.columns.length; i++) { | ||
const m: C = this.columns[i]; | ||
if (m.hidden) { continue; } | ||
|
||
const headerTarget = this.hasFrozenColumns() ? ((i <= this._options.frozenColumn!) ? this._headerL : this._headerR) : this._headerL; | ||
const headerRowTarget = this.hasFrozenColumns() ? ((i <= this._options.frozenColumn!) ? this._headerRowL : this._headerRowR) : this._headerRowL; | ||
|
||
|
@@ -1909,16 +1911,17 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
let frozenLeftColMaxWidth = 0; | ||
|
||
const children: HTMLElement[] = this.getHeaderChildren(); | ||
const vc = this.getVisibleColumns(); | ||
for (let i = 0; i < children.length; i++) { | ||
const child = children[i]; | ||
const handles = child.querySelectorAll('.slick-resizable-handle'); | ||
handles.forEach((handle) => handle.remove()); | ||
|
||
if (i >= this.columns.length || !this.columns[i] || this.columns[i].hidden) { | ||
if (i >= vc.length || !vc[i]) { | ||
continue; | ||
} | ||
|
||
if (this.columns[i].resizable) { | ||
if (vc[i].resizable) { | ||
if (firstResizable === undefined) { | ||
firstResizable = i; | ||
} | ||
|
@@ -1933,7 +1936,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
for (let i = 0; i < children.length; i++) { | ||
const colElm = children[i]; | ||
|
||
if (i >= this.columns.length || !this.columns[i] || this.columns[i].hidden) { | ||
if (i >= vc.length || !vc[i]) { | ||
continue; | ||
} | ||
if (i < firstResizable || (this._options.forceFitColumns && i >= lastResizable)) { | ||
|
@@ -1959,18 +1962,18 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
let stretchLeewayOnRight: number | null = null; | ||
// lock each column's width option to current width | ||
for (let pw = 0; pw < children.length; pw++) { | ||
if (pw >= this.columns.length || !this.columns[pw] || this.columns[pw].hidden) { | ||
if (pw >= vc.length || !vc[pw]) { | ||
continue; | ||
} | ||
this.columns[pw].previousWidth = children[pw].offsetWidth; | ||
vc[pw].previousWidth = children[pw].offsetWidth; | ||
} | ||
if (this._options.forceFitColumns) { | ||
shrinkLeewayOnRight = 0; | ||
stretchLeewayOnRight = 0; | ||
// colums on right affect maxPageX/minPageX | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
if (c && c.resizable && !c.hidden) { | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (c && c.resizable) { | ||
if (stretchLeewayOnRight !== null) { | ||
if (c.maxWidth) { | ||
stretchLeewayOnRight += c.maxWidth - (c.previousWidth || 0); | ||
|
@@ -1986,8 +1989,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
let stretchLeewayOnLeft: number | null = 0; | ||
for (j = 0; j <= i; j++) { | ||
// columns on left only affect minPageX | ||
c = this.columns[j]; | ||
if (c && c.resizable && !c.hidden) { | ||
c = vc[j]; | ||
if (c && c.resizable) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could use optional chaining here too |
||
if (stretchLeewayOnLeft !== null) { | ||
if (c.maxWidth) { | ||
stretchLeewayOnLeft += c.maxWidth - (c.previousWidth || 0); | ||
|
@@ -2027,7 +2030,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
x = d; | ||
|
||
for (j = i; j >= 0; j--) { | ||
c = this.columns[j]; | ||
c = vc[j]; | ||
if (c && c.resizable && !c.hidden) { | ||
actualMinWidth = Math.max(c.minWidth || 0, this.absoluteColumnMinWidth); | ||
if (x && (c.previousWidth || 0) + x < actualMinWidth) { | ||
|
@@ -2041,7 +2044,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
} | ||
|
||
for (k = 0; k <= i; k++) { | ||
c = this.columns[k]; | ||
c = vc[k]; | ||
if (!c || c.hidden) { continue; } | ||
|
||
if (this.hasFrozenColumns() && (k > this._options.frozenColumn!)) { | ||
|
@@ -2053,8 +2056,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
|
||
if (this._options.forceFitColumns) { | ||
x = -d; | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
if (c.resizable) { | ||
if (x && c.maxWidth && (c.maxWidth - (c.previousWidth || 0) < x)) { | ||
|
@@ -2073,8 +2076,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
} | ||
} | ||
} else { | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
|
||
if (this.hasFrozenColumns() && (j > this._options.frozenColumn!)) { | ||
|
@@ -2087,8 +2090,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
|
||
if (this._options.forceFitColumns) { | ||
x = -d; | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
if (c.resizable) { | ||
if (x && c.maxWidth && (c.maxWidth - (c.previousWidth || 0) < x)) { | ||
|
@@ -2108,7 +2111,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
newCanvasWidthR = 0; | ||
|
||
for (j = i; j >= 0; j--) { | ||
c = this.columns[j]; | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
if (c.resizable) { | ||
if (x && c.maxWidth && (c.maxWidth - (c.previousWidth || 0) < x)) { | ||
|
@@ -2133,7 +2136,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
} | ||
|
||
for (k = 0; k <= i; k++) { | ||
c = this.columns[k]; | ||
c = vc[k]; | ||
if (!c || c.hidden) { continue; } | ||
|
||
if (this.hasFrozenColumns() && (k > this._options.frozenColumn!)) { | ||
|
@@ -2145,8 +2148,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
|
||
if (this._options.forceFitColumns) { | ||
x = -d; | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
if (c.resizable) { | ||
actualMinWidth = Math.max(c.minWidth || 0, this.absoluteColumnMinWidth); | ||
|
@@ -2166,8 +2169,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
} | ||
} | ||
} else { | ||
for (j = i + 1; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = i + 1; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
|
||
if (this.hasFrozenColumns() && (j > this._options.frozenColumn!)) { | ||
|
@@ -2202,8 +2205,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e | |
this.applyColumnHeaderWidths(); | ||
} | ||
let newWidth; | ||
for (j = 0; j < this.columns.length; j++) { | ||
c = this.columns[j]; | ||
for (j = 0; j < vc.length; j++) { | ||
c = vc[j]; | ||
if (!c || c.hidden) { continue; } | ||
newWidth = children[j].offsetWidth; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could use optional chaining here
?.
you can see more info on MDN optional chaining