Skip to content

Instantly share code, notes, and snippets.

@MikeTatsky
Last active April 1, 2019 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeTatsky/635cd3edfe57ca00af83910799946af2 to your computer and use it in GitHub Desktop.
Save MikeTatsky/635cd3edfe57ca00af83910799946af2 to your computer and use it in GitHub Desktop.
Sync columns resize for ag-Grid
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