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
Changes from 1 commit
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
Next Next commit
Fix OnCellValueChange event returning newValue = oldValue
When it is triggered via SetCellData.
OS-giulianasilva committed Feb 17, 2025

Verified

This commit was signed with the committer’s verified signature.
OS-giulianasilva Giuliana Silva
commit 564904ad1023f24eaf1acebdafced4ca6c6ce8fb
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.
4 changes: 3 additions & 1 deletion src/OSFramework/DataGrid/Feature/IValidationMark.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@ namespace OSFramework.DataGrid.Feature {
validateCell(
rowNumber: number,
column: OSFramework.DataGrid.Column.IColumn,
triggerOnCellValueChange: boolean
currValue?: unknown,
oldValue?: unknown,
triggerOnCellValueChange?: boolean
): void;
validateRow(rowNumber: number): void;
// clearByRow(row: number): void;
5 changes: 3 additions & 2 deletions src/OutSystems/GridAPI/Cell.ts
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ namespace OutSystems.GridAPI.Cells {
const grid = GridManager.GetGridById(gridID);
const column = grid.getColumn(columnID);
if (column === undefined) return;
grid.features.validationMark.validateCell(rowIndex, column, triggerOnCellValueChange);
grid.features.validationMark.validateCell(rowIndex, column, null, null, triggerOnCellValueChange);
Performance.SetMark('Cells.validateCell-end');
Performance.GetMeasure('@datagrid-Cells.validateCell', 'Cells.validateCell', 'Cells.validateCell-end');
}
@@ -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, value, oldValue, triggerOnCellValueChange);
},
});

9 changes: 1 addition & 8 deletions src/Providers/DataGrid/Wijmo/Columns/DropdownColumn.ts
Original file line number Diff line number Diff line change
@@ -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, "", originalValue, true);
}
}

4 changes: 4 additions & 0 deletions src/Providers/DataGrid/Wijmo/Features/CellData.ts
Original file line number Diff line number Diff line change
@@ -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);
11 changes: 7 additions & 4 deletions src/Providers/DataGrid/Wijmo/Features/ValidationMark.ts
Original file line number Diff line number Diff line change
@@ -600,17 +600,20 @@ namespace Providers.DataGrid.Wijmo.Feature {
public validateCell(
rowNumber: number,
column: OSFramework.DataGrid.Column.IColumn,
triggerOnCellValueChange = true
currValue: unknown,
oldValue: unknown,
triggerOnCellValueChange: boolean
): 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);
}
}