-
Notifications
You must be signed in to change notification settings - Fork 159
Grid Cell merging #16024
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
Grid Cell merging #16024
Changes from 87 commits
7562cc5
f42bb3c
870e7f6
bb4e39f
e160c65
4667bb0
febbd43
4c5d922
a42b192
1361952
407357f
f23dd6c
f6ffa42
4d1b981
aca57ee
e168c3a
02b866a
d515e97
95e5b40
759b465
9329079
19c2efe
52860e8
16d4ac6
f81bd27
2ba947e
95d0186
2a65bc2
5c4587f
7ac17e4
401370e
5e1b702
58e6bfa
5e81bf9
b2b61a7
9a7a2d2
ce0c854
a6fc511
d025473
190f29d
50e7d85
1e560e8
7db787a
86bc021
91c457b
a5c5566
46ea7ae
f862469
fc46739
ea9baa6
1f4c554
94eb0a8
cc47820
35a1bde
a7970d1
5ab08a8
229bcd1
e64ee01
238390f
c071635
9f1ffd0
0ae58e0
2267e03
6178a23
d044219
b8a77e2
0351166
9cc56b6
cbf4a1c
e491681
5d2a5ce
db23777
3f7c27e
2bbd9b8
bcae71b
c081168
2d6b443
2a9726d
f69b105
13b4c24
05e42c6
e46786e
a06132a
5528867
4f75644
968363c
b052b64
8e45f72
d6b9e8e
e235e83
88e01da
e91b097
6e103ac
75fd965
69b272c
1a4fbd9
0483273
6d148a4
a17df96
a892a57
a503659
69ba10d
638df68
173532f
4d1c477
4c7495e
f624236
17dd6c0
514ad96
c5507de
7e15c92
e406dee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -622,6 +622,7 @@ | |
|
||
%grid-row--mrl { | ||
%igx-grid__hierarchical-expander--header, | ||
%igx-grid__hierarchical-expander, | ||
%igx-grid__header-indentation, | ||
%igx-grid__row-indentation, | ||
%grid__cbx-selection { | ||
|
@@ -754,6 +755,7 @@ | |
} | ||
|
||
%grid__cbx-selection, | ||
%igx-grid__hierarchical-expander, | ||
%igx-grid__row-indentation, | ||
%igx-grid__drag-indicator { | ||
border-bottom: rem(1px) solid var-get($theme, 'row-border-color'); | ||
|
@@ -1338,6 +1340,35 @@ | |
} | ||
} | ||
|
||
%igx-grid__tr--merged { | ||
border-bottom: 0px; | ||
} | ||
|
||
%igx-grid__tr--merged-top { | ||
position: absolute; | ||
width: 100%; | ||
} | ||
|
||
%igx-grid__td--merged { | ||
z-index: 1; | ||
grid-row: 1 / -1; | ||
} | ||
|
||
%igx-grid__td--merged-selected { | ||
color: var-get($theme, 'row-selected-text-color'); | ||
background: var-get($theme, 'row-selected-background') !important; | ||
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. Why is important needed here and in the consequent placeholder selectors? 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. It's because if the pinned cell style:
It overwrites the background, when the cell is also pinned. |
||
} | ||
|
||
%igx-grid__td--merged-hovered { | ||
background: var-get($theme, 'row-hover-background') !important; | ||
color: var-get($theme, 'row-hover-text-color'); | ||
} | ||
|
||
%igx-grid__td--merged-selected-hovered { | ||
background: var-get($theme, 'row-selected-hover-background') !important; | ||
color: var-get($theme, 'row-selected-hover-text-color'); | ||
} | ||
simeonoff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
%igx-grid__tr--deleted { | ||
%grid-cell-text { | ||
font-style: italic; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { GridType } from '../grids/common/grid.interface'; | ||
|
||
|
||
|
||
|
||
export interface IMergeByResult { | ||
rowSpan: number; | ||
root?: any; | ||
prev?: any; | ||
mddragnev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
export interface IGridMergeStrategy { | ||
/* blazorSuppress */ | ||
merge: ( | ||
mddragnev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
data: any[], | ||
field: string, | ||
comparer: (prevRecord: any, currentRecord: any, field: string) => boolean, | ||
result: any[], | ||
activeRowIndexes : number[], | ||
grid?: GridType | ||
) => any[]; | ||
comparer: (prevRecord: any, record: any, field: string) => boolean; | ||
} | ||
|
||
export class DefaultMergeStrategy implements IGridMergeStrategy { | ||
protected static _instance: DefaultMergeStrategy = null; | ||
|
||
public static instance(): DefaultMergeStrategy { | ||
return this._instance || (this._instance = new this()); | ||
} | ||
|
||
/* blazorSuppress */ | ||
public merge( | ||
data: any[], | ||
field: string, | ||
comparer: (prevRecord: any, record: any, field: string) => boolean = this.comparer, | ||
result: any[], | ||
activeRowIndexes : number[], | ||
grid?: GridType | ||
) { | ||
let prev = null; | ||
let index = 0; | ||
for (const rec of data) { | ||
|
||
const recData = result[index]; | ||
// if this is active row or some special record type - add and skip merging | ||
if (activeRowIndexes.indexOf(index) != -1 || (grid && grid.isDetailRecord(rec) || grid.isGroupByRecord(rec) || grid.isChildGridRecord(rec))) { | ||
if(!recData) { | ||
result.push(rec); | ||
} | ||
prev = null; | ||
index++; | ||
continue; | ||
} | ||
let recToUpdateData = recData ?? { recordRef: grid.isGhostRecord(rec) ? rec.recordRef : rec, cellMergeMeta: new Map<string, IMergeByResult>(), ghostRecord: rec.ghostRecord }; | ||
recToUpdateData.cellMergeMeta.set(field, { rowSpan: 1 }); | ||
if (prev && comparer(prev.recordRef, recToUpdateData.recordRef, field) && prev.ghostRecord === recToUpdateData.ghostRecord) { | ||
const root = prev.cellMergeMeta.get(field)?.root ?? prev; | ||
root.cellMergeMeta.get(field).rowSpan += 1; | ||
recToUpdateData.cellMergeMeta.get(field).root = root; | ||
} | ||
prev = recToUpdateData; | ||
if (!recData) { | ||
result.push(recToUpdateData); | ||
} | ||
index++; | ||
} | ||
return result; | ||
} | ||
|
||
/* blazorSuppress */ | ||
public comparer(prevRecord: any, record: any, field: string): boolean { | ||
const a = prevRecord[field]; | ||
const b = record[field]; | ||
const an = (a === null || a === undefined); | ||
const bn = (b === null || b === undefined); | ||
if (an) { | ||
if (bn) { | ||
return true; | ||
} | ||
return false; | ||
} else if (bn) { | ||
return false; | ||
} | ||
return a === b; | ||
} | ||
} | ||
|
||
|
||
export class DefaultTreeGridMergeStrategy extends DefaultMergeStrategy { | ||
/* blazorSuppress */ | ||
public override comparer(prevRecord: any, record: any, field: string): boolean { | ||
const a = prevRecord.data[field]; | ||
const b = record.data[field]; | ||
const an = (a === null || a === undefined); | ||
const bn = (b === null || b === undefined); | ||
if (an) { | ||
if (bn) { | ||
return true; | ||
} | ||
return false; | ||
} else if (bn) { | ||
return false; | ||
} | ||
return a === b; | ||
} | ||
} | ||
|
||
export class ByLevelTreeGridMergeStrategy extends DefaultMergeStrategy { | ||
/* blazorSuppress */ | ||
public override comparer(prevRecord: any, record: any, field: string): boolean { | ||
const a = prevRecord.data[field]; | ||
const b = record.data[field]; | ||
const levelA = prevRecord.level; | ||
const levelB = record.level; | ||
const an = (a === null || a === undefined); | ||
const bn = (b === null || b === undefined); | ||
if (an) { | ||
if (bn) { | ||
return true; | ||
} | ||
return false; | ||
} else if (bn) { | ||
return false; | ||
} | ||
return a === b && levelA === levelB; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.