separated column pinnd fun
This commit is contained in:
parent
817cfb2731
commit
c615678981
40
src/services/pmsGrid/GridPinnedCalculator.js
Normal file
40
src/services/pmsGrid/GridPinnedCalculator.js
Normal file
@ -0,0 +1,40 @@
|
||||
// GridPinnedCalculator.js
|
||||
export function computeLeftOffsets(colState) {
|
||||
const ordered = colState
|
||||
.filter((c) => c.visible)
|
||||
.sort((a, b) => a.order - b.order);
|
||||
|
||||
let offset = 0;
|
||||
const map = {};
|
||||
|
||||
for (const col of ordered) {
|
||||
if (col.pinned === "left") {
|
||||
map[col.key] = offset;
|
||||
offset += col.width || 120;
|
||||
} else {
|
||||
map[col.key] = null; // not pinned-left
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
export function computeRightOffsets(colState) {
|
||||
const ordered = colState
|
||||
.filter((c) => c.visible)
|
||||
.sort((a, b) => b.order - a.order);
|
||||
|
||||
let offset = 0;
|
||||
const map = {};
|
||||
|
||||
for (const col of ordered) {
|
||||
if (col.pinned === "right") {
|
||||
map[col.key] = offset;
|
||||
offset += col.width || 120;
|
||||
} else {
|
||||
map[col.key] = null; // not pinned-right
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user