Skip to content

Commit

Permalink
fix(resize): columns reposition not coming back after grid setOptions
Browse files Browse the repository at this point in the history
- when using SF custom grid view with `changeColumnsArrangement()` and then calling SlickGrid `setOptions`, the columns positions were reverting back to their original positions because of the `setOptions` 3rd argument that calls internally `treeColumns.extractColumns()` which reverts column positions, there must be something wrong in that SlickGrid internal code but for now a quick fix is to set the `setOptions` 3rd argument to `true` and right after we need to call `reRenderColumns` so that all grid options (like `editable` toggling) are reflected correctly in the grid
  • Loading branch information
ghiscoding committed Apr 21, 2021
1 parent 515a072 commit f2027e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ const mockGrid = {
updateRow: jest.fn(),
render: jest.fn(),
registerPlugin: jest.fn(),
reRenderColumns: jest.fn(),
resizeCanvas: jest.fn(),
setColumns: jest.fn(),
setHeaderRowVisibility: jest.fn(),
Expand Down Expand Up @@ -623,7 +624,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()

expect(component.gridOptions.autoCommitEdit).toEqual(false);
// expect(component.gridOptions.autoResize.bottomPadding).toEqual(50 + DATAGRID_FOOTER_HEIGHT); // calculated by the lib
expect(setOptionSpy).toBeCalledWith(component.gridOptions);
expect(setOptionSpy).toBeCalledWith(component.gridOptions, false, true);
expect(sharedOptionSpy).toBeCalledWith(component.gridOptions);
});

Expand All @@ -638,7 +639,7 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()
component.dataset = mockData;

expect(component.gridOptions.autoCommitEdit).toEqual(false);
expect(setOptionSpy).toBeCalledWith(component.gridOptions);
expect(setOptionSpy).toBeCalledWith(component.gridOptions, false, true);
expect(sharedOptionSpy).toBeCalledWith(component.gridOptions);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ export class SlickVanillaGridBundle {
}
if (this.sharedService?.gridOptions && this.slickGrid?.setOptions) {
this.sharedService.gridOptions = mergedOptions;
this.slickGrid.setOptions(mergedOptions);
this.slickGrid.setOptions(mergedOptions, false, true); // make sure to supressColumnCheck (3rd arg) to avoid problem with changeColumnsArrangement() and custom grid view
this.slickGrid.reRenderColumns(true); // then call a re-render since we did supressColumnCheck on previous setOptions
}
this._gridOptions = mergedOptions;
}
Expand Down

0 comments on commit f2027e6

Please sign in to comment.