Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins): rollback PR #781 to fix regression with Grid Presets #820

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,11 @@ export class Example7 {
this.sgb.columnDefinitions.pop();
this.sgb.columnDefinitions = this.sgb.columnDefinitions.slice();

// NOTE if you use an Extensions (Row Move, Row Detail, Row Selections) that modifies the column definitions in any way
// it will update the column definitions but only on the sgb instance, so you can use "this.sgb.columnDefinitions" to get full list.
// However please note that this will ALWAYS return all columns in their original positions,
// in other words, if you change column reordering, that unfortunately won't be reflected.
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
// you MUST use the code below, first you must reassign the Editor facade (from the internalColumnEditor back to the editor)
// in other words, SlickGrid is not using the same as Slickgrid-Universal uses (editor with a "model" and other properties are a facade, SlickGrid only uses what is inside the model)
/*
const allOriginalColumns = this.sgb.columnDefinitions(); // or: this.slickerGridInstance.gridService.getAllColumnDefinitions();
const allOriginalColumns = this.slickerGridInstance.gridService.getAllColumnDefinitions();
const allOriginalColumns = allOriginalColumns.map((column) => {
column.editor = column.internalColumnEditor;
return column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ describe('Slick-Vanilla-Grid-Bundle Component instantiated via Constructor', ()
expect(pubSubSpy).toHaveBeenNthCalledWith(6, 'onAfterGridDestroyed', true);
});

it('should update column definitions when onPluginColumnsChanged event is triggered with updated columns', () => {
// TODO: revisit later, this is conflicting with Grid State & Presets
it.skip('should update column definitions when onPluginColumnsChanged event is triggered with updated columns', () => {
const columnsMock = [
{ id: 'firstName', field: 'firstName', editor: undefined, internalColumnEditor: {} },
{ id: 'lastName', field: 'lastName', editor: undefined, internalColumnEditor: {} }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,14 @@ export class SlickVanillaGridBundle {
this.sharedService.allColumns = this._columnDefinitions;
this.sharedService.visibleColumns = this._columnDefinitions;

// TODO: revisit later, this is conflicting with Grid State & Presets
// before certain extentions/plugins potentially adds extra columns not created by the user itself (RowMove, RowDetail, RowSelections)
// we'll subscribe to the event and push back the change to the user so they always use full column defs array including extra cols
this.subscriptions.push(
this._eventPubSubService.subscribe<{ columns: Column[]; pluginName: string }>('onPluginColumnsChanged', data => {
this._columnDefinitions = this.columnDefinitions = data.columns;
})
);
// this.subscriptions.push(
// this._eventPubSubService.subscribe<{ columns: Column[]; pluginName: string }>('onPluginColumnsChanged', data => {
// this._columnDefinitions = this.columnDefinitions = data.columns;
// })
// );

// after subscribing to potential columns changed, we are ready to create these optional extensions
// when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
Expand Down