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

ROU-4689: Implement a way to preserve the Grid's Layout when editing configs in runtime #391

Merged
merged 7 commits into from
Jan 16, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace OSFramework.DataGrid.Configuration.Column {
public uniqueId: string;
public validateBinding: boolean;
public visible: boolean;
public width: number;

constructor(
config: DataGrid.Types.IColumnConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ namespace OSFramework.DataGrid.Configuration {
* Determines whether or not the column is visible
*/
visible: boolean;
/**
* Determines whether or not the column is visible
*/
width: number;
/**
* Refresh config
* @param providerConfig The config based on provider, used to update our internal config
Expand Down
19 changes: 19 additions & 0 deletions src/Providers/DataGrid/Wijmo/Grid/FlexGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Providers.DataGrid.Wijmo.Grid {
implements IGridWijmo
{
private _fBuilder: Feature.FeatureBuilder;
private _resizedColumnHandler: OSFramework.DataGrid.Callbacks.Generic;
rugoncalves marked this conversation as resolved.
Show resolved Hide resolved
private _rowMetadata: RowMetadata;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -84,6 +85,17 @@ namespace Providers.DataGrid.Wijmo.Grid {
return this.config.getProviderConfig();
}

private _updateColumnWidth(
grid: wijmo.grid.FlexGrid,
event: wijmo.grid.CellRangeEventArgs
): void {
const columnProvider = event.getColumn();
const columnOS = this.getColumn(columnProvider.binding);
if (columnOS) {
columnOS.config.width = columnProvider.width;
}
}

public get autoGenerate(): boolean {
return this.provider.autoGenerateColumns;
}
Expand Down Expand Up @@ -127,6 +139,9 @@ namespace Providers.DataGrid.Wijmo.Grid {
this._provider.itemsSource.calculatedFields =
this.features.calculatedField.calculatedFields;

this._resizedColumnHandler = this._updateColumnWidth.bind(this);
this._provider.resizedColumn.addHandler(this._resizedColumnHandler);

this._safari14workaround();

this.finishBuild();
Expand Down Expand Up @@ -299,6 +314,10 @@ namespace Providers.DataGrid.Wijmo.Grid {

this._fBuilder.dispose();

this._provider.resizedColumn.removeHandler(
this._resizedColumnHandler
);

this._provider.dispose();
this._provider = undefined;
}
Expand Down
Loading