Last active
April 1, 2019 06:36
-
-
Save MikeTatsky/635cd3edfe57ca00af83910799946af2 to your computer and use it in GitHub Desktop.
Sync columns resize for ag-Grid
This file contains hidden or 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
onColumnResized = { | |
(e) => { | |
if (rootStore.viewGrids.length === 1) { | |
return; | |
} | |
if (window._agGridActiveResizeGridIndex !== undefined && window._agGridActiveResizeGridIndex !== gridIndex) { | |
return; | |
} | |
if (!e.finished) { | |
window._agGridActiveResizeGridIndex = gridIndex; | |
let column = e.column; | |
let colId = column.colId; | |
let newWidth = column.actualWidth; | |
if (this.columnResizeInterval) { | |
clearInterval(this.columnResizeInterval); | |
} | |
this.columnResizeInterval = setTimeout(() => { | |
rootStore.viewGrids.map((grid, i) => { | |
if (i === gridIndex) { | |
return; | |
} | |
grid.columnApi.setColumnWidth(colId, newWidth, true); | |
}); | |
delete window._agGridActiveResizeGridIndex; | |
delete window.columnResizeInterval; | |
}, 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment