Skip to content

Commit 84a51fd

Browse files
authored
Merge branch 'master' into iminchev/fix-16493-21.1.x
2 parents 7257546 + 4dfd9c1 commit 84a51fd

21 files changed

Lines changed: 314 additions & 143 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { GridTypeBase, IgxCsvExporterOptions, IgxCsvExporterService } from 'igniteui-angular';
2+
3+
export class IgcCsvExporterService extends IgxCsvExporterService {
4+
public override export(grid: GridTypeBase, options: IgxCsvExporterOptions): void {
5+
const gridRef = (grid as any).ngElementStrategy?.componentRef?.instance;
6+
super.export(gridRef || grid, options);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { GridTypeBase, IgxExcelExporterOptions, IgxExcelExporterService } from 'igniteui-angular';
2+
3+
export class IgcExcelExporterService extends IgxExcelExporterService {
4+
public override export(grid: GridTypeBase, options: IgxExcelExporterOptions): void {
5+
const gridRef = (grid as any).ngElementStrategy?.componentRef?.instance;
6+
super.export(gridRef || grid, options);
7+
}
8+
}

projects/igniteui-angular-elements/src/public_api.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { registerI18n, setCurrentI18n } from 'igniteui-i18n-core';
22
import { ByLevelTreeGridMergeStrategy, ColumnPinningPosition, DefaultMergeStrategy, DefaultTreeGridMergeStrategy, FilteringExpressionsTree, FilteringExpressionsTreeType, FilteringLogic, HorizontalAlignment, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxDateTimeFilteringOperand, IgxFilteringOperand, IgxNumberFilteringOperand, IgxStringFilteringOperand, IgxTimeFilteringOperand, NoopFilteringStrategy, NoopSortingStrategy, SortingDirection, TransactionType, TransactionEventOrigin, VerticalAlignment } from 'igniteui-angular/core';
3-
import { DropPosition, GridPagingMode, IgxDateSummaryOperand, IgxNumberSummaryOperand, IgxPivotAggregate, IgxPivotDateAggregate, IgxPivotDateDimension, IgxPivotNumericAggregate, IgxPivotTimeAggregate, IgxSummaryOperand, IgxTimeSummaryOperand, NoopPivotDimensionsStrategy, PivotDimensionType, RowPinningPosition } from 'igniteui-angular/grids/core';
3+
import { CsvFileTypes, DropPosition, GridPagingMode, IgxCsvExporterOptions, IgxDateSummaryOperand, IgxExcelExporterOptions, IgxNumberSummaryOperand, IgxPivotAggregate, IgxPivotDateAggregate, IgxPivotDateDimension, IgxPivotNumericAggregate, IgxPivotTimeAggregate, IgxSummaryOperand, IgxTimeSummaryOperand, NoopPivotDimensionsStrategy, PivotDimensionType, RowPinningPosition } from 'igniteui-angular/grids/core';
4+
import { IgcExcelExporterService } from './lib/excel-exporter';
5+
import { IgcCsvExporterService } from './lib/csv-exporter';
46

57
/** Export Public API, TODO: reorganize, Generate all w/ renames? */
68
export {
@@ -53,4 +55,11 @@ export {
5355
// Transactions API
5456
TransactionType,
5557
TransactionEventOrigin,
58+
59+
// Exporters
60+
IgxExcelExporterOptions as IgcExcelExporterOptions,
61+
IgxCsvExporterOptions as IgcCsvExporterOptions,
62+
IgcExcelExporterService,
63+
IgcCsvExporterService,
64+
CsvFileTypes
5665
}

projects/igniteui-angular/grids/core/src/filtering/excel-style/excel-style-search.component.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,26 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
482482
const matchedData = cloneHierarchicalArray(this.esf.listData, 'children');
483483
this.displayedListData = this.hierarchicalSelectMatches(matchedData, searchVal);
484484
this.cdr.detectChanges();
485+
/**
486+
* There are two calls of `matchesNumericValue` in this method: one when we generate the displayedListData in hierarchicalSelectMatches method
487+
* and another one when going through the tree nodes. We can avoid the second call by storing the items in a set.
488+
* However, if the datasource is small there is no significant difference in performance but we would be adding extra memory overhead.
489+
* We should test this when https://github.com/IgniteUI/igniteui-angular/issues/17144 issue is fixed with 100k or 1m records
490+
*/
485491
this.tree.nodes.forEach(n => {
486492
n.selected = true;
487-
if ((n.data as FilterListItem).label.toString().toLowerCase().indexOf(searchVal) > -1) {
493+
const item = n.data as FilterListItem;
494+
if (item.label.toString().toLowerCase().indexOf(searchVal) > -1 ||
495+
this.matchesNumericValue(item, searchVal)) {
488496
this.expandAllParentNodes(n);
489497
}
490498
});
491499
} else {
492500
this.displayedListData = this.esf.listData.filter((it, i) => (i === 0 && it.isSpecial) ||
493501
(it.label !== null && it.label !== undefined) &&
494502
!it.isBlanks &&
495-
it.label.toString().toLowerCase().indexOf(searchVal) > -1);
503+
(it.label.toString().toLowerCase().indexOf(searchVal) > -1 ||
504+
this.matchesNumericValue(it, searchVal)));
496505

497506
this.esf.listData.forEach(i => i.isSelected = false);
498507
this.displayedListData.forEach(i => i.isSelected = true);
@@ -724,7 +733,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
724733
node.expanded = false;
725734
}
726735

727-
if (element.label.toString().toLowerCase().indexOf(searchVal) > -1) {
736+
if (element.label.toString().toLowerCase().indexOf(searchVal) > -1 ||
737+
this.matchesNumericValue(element, searchVal)) {
728738
element.isSelected = true;
729739
this.hierarchicalSelectAllChildren(element);
730740
this._hierarchicalSelectedItems.push(element);
@@ -802,6 +812,23 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
802812
}
803813
}
804814

815+
private matchesNumericValue(item: FilterListItem, searchVal: string): boolean {
816+
const columnDataType = this.esf.column?.dataType;
817+
if (typeof item.value !== 'number' ||
818+
(columnDataType !== GridColumnDataType.Number &&
819+
columnDataType !== GridColumnDataType.Currency &&
820+
columnDataType !== GridColumnDataType.Percent)) {
821+
return false;
822+
}
823+
824+
let numericValue = item.value;
825+
if (columnDataType === GridColumnDataType.Percent) {
826+
numericValue = parseFloat((item.value * 100).toPrecision(15));
827+
}
828+
829+
return numericValue.toString().toLowerCase().indexOf(searchVal) > -1;
830+
}
831+
805832
private onArrowUpKeyDown() {
806833
if (this.focusedItem && this.focusedItem.index === 0 && this.virtDir.state.startIndex === 0) {
807834
// on ArrowUp the focus stays on the same element if it is the first focused

projects/igniteui-angular/grids/core/src/services/csv/csv-exporter-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IgxExporterOptionsBase } from '../exporter-common/exporter-options-base';
22

3+
/* csSuppress */
34
/**
45
* Objects of this class are used to configure the CSV exporting process.
56
*/

projects/igniteui-angular/grids/core/src/services/csv/csv-exporter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { CharSeparatedValueData } from './char-separated-value-data';
55
import { CsvFileTypes, IgxCsvExporterOptions } from './csv-exporter-options';
66
import { IBaseEventArgs } from 'igniteui-angular/core';
77

8+
/* csSuppress */
89
export interface ICsvExportEndedEventArgs extends IBaseEventArgs {
910
csvData?: string;
1011
}
1112

13+
/* csSuppress */
1214
/**
1315
* **Ignite UI for Angular CSV Exporter Service** -
1416
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/exporter-csv)

projects/igniteui-angular/grids/core/src/services/excel/excel-exporter-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IgxExporterOptionsBase } from '../exporter-common/exporter-options-base';
22

3+
/* csSuppress */
34
/**
45
* Objects of this class are used to configure the Excel exporting process.
56
*/

projects/igniteui-angular/grids/core/src/services/excel/excel-exporter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import { WorksheetData } from './worksheet-data';
1111
import { WorksheetFile } from './excel-files';
1212
import { IBaseEventArgs } from 'igniteui-angular/core';
1313

14+
/* csSuppress */
1415
export interface IExcelExportEndedEventArgs extends IBaseEventArgs {
1516
xlsx?: Object
1617
}
1718

1819
const EXCEL_MAX_ROWS = 1048576;
1920
const EXCEL_MAX_COLS = 16384;
2021

22+
/* csSuppress */
2123
/**
2224
* **Ignite UI for Angular Excel Exporter Service** -
2325
* [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/exporter_excel.html)

projects/igniteui-angular/grids/core/src/services/exporter-common/base-export-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export abstract class IgxBaseExporter {
225225
*
226226
* @memberof IgxBaseExporter
227227
*/
228-
public export(grid: any, options: IgxExporterOptionsBase): void {
228+
public export(grid: GridTypeBase, options: IgxExporterOptionsBase): void {
229229
if (options === undefined || options === null) {
230230
throw Error('No options provided!');
231231
}

projects/igniteui-angular/grids/grid/src/grid-filtering-ui.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,6 +4113,25 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
41134113
expect(listItems.length).toBe(8, 'incorrect rendered list items count');
41144114
});
41154115

4116+
it('Should match numeric column values when searching without locale-specific formatting characters.', async () => {
4117+
GridFunctions.clickExcelFilterIconFromCodeAsync(fix, grid, 'Downloads');
4118+
fix.detectChanges();
4119+
await wait(100);
4120+
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4121+
const inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix, searchComponent);
4122+
4123+
// Type 1000 (without thousands separator) in search box.
4124+
// The value 1000 is displayed as "1,000" in the ESF list due to locale formatting.
4125+
// Searching "1000" should still match the "1,000" entry.
4126+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, '1000', fix);
4127+
fix.detectChanges();
4128+
await wait(100);
4129+
4130+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4131+
// Expect 3 items: Select All + Add to current filter + the matched "1,000" item
4132+
expect(listItems.length).toBe(3, 'searching plain number should match locale-formatted label');
4133+
});
4134+
41164135
it('Should enable/disable the apply button correctly.', async () => {
41174136
GridFunctions.clickExcelFilterIconFromCodeAsync(fix, grid, 'ProductName');
41184137
fix.detectChanges();

0 commit comments

Comments
 (0)