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-4691: Column Filter does not reflect the correct value when using FilterByCondition API #392

Merged
merged 4 commits into from
Jan 18, 2024
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
1 change: 1 addition & 0 deletions src/OSFramework/DataGrid/Enum/ErrorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace OSFramework.DataGrid.Enum {
AutoGenerateGridWrite = 'The auto generation of columns based on Data is not available when the Grid is editable. Please use ArrangeData action for this scenario.',
Column_NotFound = 'Column not found',
CustomizeExportingMessageEmptyString = 'It seems you are passing an empty message. Please pass a valid message.',
Filter_InvalidDataType = 'It seems you are trying to filter a Number/Currency column with a value that is not a number.',
FreezeColumnPositiveNumberExpected = 'Unable to freeze column. Please use a positive number.',
Grid_NotFound = 'Grid not found.',
InvalidColumnIdentifier = 'It seems you are not passing a valid column.',
Expand Down
31 changes: 27 additions & 4 deletions src/Providers/DataGrid/Wijmo/Features/ColumnFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,38 @@ namespace Providers.DataGrid.Wijmo.Feature {
const column = this._grid.getColumn(columnId);
if (column) {
const columnFilter = this._filter.getColumnFilter(
column.config.binding
column.provider
).conditionFilter;
const isNumericalColumn =
column.columnType ===
OSFramework.DataGrid.Enum.ColumnType.Calculated ||
column.columnType ===
OSFramework.DataGrid.Enum.ColumnType.Currency ||
column.columnType ===
OSFramework.DataGrid.Enum.ColumnType.Number;

if (values.length > 0) {
const condition1 = values[0];
const condition2 = values[1];

// If it is a numerical column and one of the conditions' value is not a number
// Then throw an error
if (
isNumericalColumn &&
(isNaN(parseFloat(condition1.value)) ||
(condition2 && isNaN(parseFloat(condition2.value))))
) {
throw new Error(
OSFramework.DataGrid.Enum.ErrorMessages.Filter_InvalidDataType
);
}

columnFilter.condition1.value =
this._getFilterConditionValue(
column.columnType,
condition1.value
isNumericalColumn
? parseFloat(condition1.value)
: condition1.value
);
columnFilter.condition1.operator =
wijmo.grid.filter.Operator[condition1.operatorTypeId];
Expand All @@ -210,7 +231,9 @@ namespace Providers.DataGrid.Wijmo.Feature {
columnFilter.condition2.value =
this._getFilterConditionValue(
column.columnType,
condition2.value
isNumericalColumn
? parseFloat(condition2.value)
: condition2.value
);
columnFilter.condition2.operator =
wijmo.grid.filter.Operator[
Expand Down Expand Up @@ -249,7 +272,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
OSFramework.DataGrid.Enum.ColumnType.DateTime;

const columnFilter = this._filter.getColumnFilter(
column.config.binding
column.provider
).valueFilter;

// we receive values as an array ["Brazil", "Portugal"], but wijmo expects an object
Expand Down
Loading