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-4828: Fix OnCellValueChange event returning newValue = oldValue when it is triggered via SetCellData #446

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions src/OSFramework/DataGrid/Feature/ICellData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
namespace OSFramework.DataGrid.Feature {
export interface ICellData {
getCellData(rowNumber: number, column: OSFramework.DataGrid.Column.IColumn): unknown;
/**
* Responsible for updating a specific cell -
* This is needed in a case we wnat to update another column cell, for example when a cell content is denpendent on another.
Expand Down
4 changes: 3 additions & 1 deletion src/OSFramework/DataGrid/Feature/IValidationMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ namespace OSFramework.DataGrid.Feature {
validateCell(
rowNumber: number,
column: OSFramework.DataGrid.Column.IColumn,
triggerOnCellValueChange: boolean
triggerOnCellValueChange?: boolean,
currValue?: unknown,
oldValue?: unknown
): void;
validateRow(rowNumber: number): void;
// clearByRow(row: number): void;
Expand Down
3 changes: 2 additions & 1 deletion src/OutSystems/GridAPI/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ namespace OutSystems.GridAPI.Cells {
if (showDirtyMark) {
grid.features.dirtyMark.saveOriginalValue(rowIndex, column.providerIndex);
}
const oldValue = grid.features.cellData.getCellData(rowIndex, column);
grid.features.cellData.setCellData(rowIndex, column, value);
grid.features.validationMark.validateCell(rowIndex, column, triggerOnCellValueChange);
grid.features.validationMark.validateCell(rowIndex, column, triggerOnCellValueChange, value, oldValue);
},
});

Expand Down
9 changes: 1 addition & 8 deletions src/Providers/DataGrid/Wijmo/Columns/DropdownColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,7 @@ namespace Providers.DataGrid.Wijmo.Column {
// always clear the child cell when the parent changes
this.grid.provider.setCellData(rowNumber, this.provider.index, '', true);

this.grid.features.validationMark.validateCell(rowNumber, this, false);

this.columnEvents.trigger(
OSFramework.DataGrid.Event.Column.ColumnEventType.OnCellValueChange,
'',
originalValue,
rowNumber
);
this.grid.features.validationMark.validateCell(rowNumber, this, true, "", originalValue);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Providers/DataGrid/Wijmo/Features/CellData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace Providers.DataGrid.Wijmo.Feature {
//
}

public getCellData(rowNumber: number, column: OSFramework.DataGrid.Column.IColumn): unknown {
return this._grid.provider.getCellData(rowNumber, column.provider.index, false);
}

public setCellData(rowNumber: number, column: OSFramework.DataGrid.Column.IColumn, value: string): void {
if (column.columnType === OSFramework.DataGrid.Enum.ColumnType.DateTime) {
value = this._grid.dataSource.trimSecondsFromDate(value);
Expand Down
13 changes: 8 additions & 5 deletions src/Providers/DataGrid/Wijmo/Features/ValidationMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
oldValue: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
newValue: any
) {
) : void {
const column = this._grid.getColumn(columnUniqueID);

if (column !== undefined) {
Expand Down Expand Up @@ -600,17 +600,20 @@ namespace Providers.DataGrid.Wijmo.Feature {
public validateCell(
rowNumber: number,
column: OSFramework.DataGrid.Column.IColumn,
triggerOnCellValueChange = true
triggerOnCellValueChange: boolean,
currValue: unknown,
oldValue: unknown
): void {
// This method gets executed by an API. No values change in columns, so the current value and the original one (old value) are the same.
const currValue = this._grid.provider.getCellData(rowNumber, column.provider.index, false);
const newValue = currValue ?? this._grid.provider.getCellData(rowNumber, column.provider.index, false);
const previousValue = oldValue ?? newValue;

//If we decide not to trigger the column events we will skip this step
if (triggerOnCellValueChange) {
// Triggers the events of OnCellValueChange associated to a specific column in OS
this._triggerEventsFromColumn(rowNumber, column.uniqueId, currValue, currValue);
this._triggerEventsFromColumn(rowNumber, column.uniqueId, newValue, previousValue);
} else {
this._setCellStatus(column, rowNumber, currValue);
this._setCellStatus(column, rowNumber, newValue);
}
}

Expand Down
Loading