Skip to content

Commit c083186

Browse files
committed
draggable.grid.header.toolbar.SortZone: switchItems() => add support for different column widths #6373
1 parent e0ecd98 commit c083186

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

src/draggable/grid/header/toolbar/SortZone.mjs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,31 +154,40 @@ class SortZone extends BaseSortZone {
154154
* @param {Number} index2
155155
*/
156156
switchItems(index1, index2) {
157+
super.switchItems(index1, index2);
158+
157159
if (this.moveColumnContent) {
158-
let {view} = this.owner.parent,
160+
let me = this,
161+
{itemRects} = me,
162+
{view} = me.owner.parent,
159163
columnPositions = view._columnPositions, // no clone
160164
column1Cells = view.getColumnCells(columnPositions[index1].dataField),
161-
column2Cells = view.getColumnCells(columnPositions[index2].dataField),
162-
x;
165+
column2Cells = view.getColumnCells(columnPositions[index2].dataField);
163166

164-
x = columnPositions[index1].x;
165-
columnPositions[index1].x = columnPositions[index2].x;
166-
columnPositions[index2].x = x;
167+
Object.assign(columnPositions[index1], {
168+
width: itemRects[index2].width,
169+
x : itemRects[index2].x + 1
170+
});
171+
172+
Object.assign(columnPositions[index2], {
173+
width: itemRects[index1].width,
174+
x : itemRects[index1].x + 1
175+
});
167176

168177
NeoArray.move(columnPositions, index1, index2);
169178

170179
column1Cells.forEach(node => {
171-
node.style.left = columnPositions[index2].x + 'px'
180+
node.style.left = columnPositions[index2].x + 'px';
181+
node.style.width = columnPositions[index2].width + 'px'
172182
});
173183

174184
column2Cells.forEach(node => {
175-
node.style.left = columnPositions[index1].x + 'px'
185+
node.style.left = columnPositions[index1].x + 'px';
186+
node.style.width = columnPositions[index1].width + 'px'
176187
});
177188

178189
view.update()
179190
}
180-
181-
super.switchItems(index1, index2);
182191
}
183192
}
184193

0 commit comments

Comments
 (0)