Skip to content

Commit 080f407

Browse files
authored
Merge branch '11.1.x' into gedinakova/fix-9465-11.1
2 parents 04b360e + 2467fcc commit 080f407

File tree

3 files changed

+63
-34
lines changed

3 files changed

+63
-34
lines changed

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { GridBaseAPIService } from '../../api.service';
3131
import { FormattedValuesFilteringStrategy } from '../../../data-operations/filtering-strategy';
3232
import { TreeGridFormattedValuesFilteringStrategy } from '../../tree-grid/tree-grid.filtering.strategy';
3333
import { getLocaleCurrencyCode } from '@angular/common';
34+
import { SortingDirection } from '../../../data-operations/sorting-expression.interface';
3435

3536
/**
3637
* @hidden
@@ -611,7 +612,8 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
611612
this.addItems(shouldUpdateSelection);
612613
}
613614

614-
this.listData.sort((a, b) => this.sortData(a, b));
615+
this.listData = this.column.sortStrategy.sort(this.listData, 'value', SortingDirection.Asc, this.column.sortingIgnoreCase,
616+
(obj, key) => obj[key]);
615617

616618
if (this.containsNullOrEmpty) {
617619
this.addBlanksItem(shouldUpdateSelection);
@@ -756,22 +758,6 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
756758
this.listData.unshift(blanks);
757759
}
758760

759-
private sortData(a: FilterListItem, b: FilterListItem) {
760-
let valueA = a.value;
761-
let valueB = b.value;
762-
if (typeof(a) === DataType.String) {
763-
valueA = a.value.toUpperCase();
764-
valueB = b.value.toUpperCase();
765-
}
766-
if (valueA < valueB) {
767-
return -1;
768-
} else if (valueA > valueB) {
769-
return 1;
770-
} else {
771-
return 0;
772-
}
773-
}
774-
775761
private getFilterItemLabel(element: any, applyFormatter: boolean = true) {
776762
if (this.column.dataType === DataType.Date) {
777763
return element && element.label ? element.label : this.column.formatter ?

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

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,8 +4080,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
40804080
fix.detectChanges();
40814081

40824082
verifyExcelStyleFilterAvailableOptions(fix,
4083-
['Select All', '(Blanks)', '0', '20', '100', '127', '254'],
4084-
[true, true, true, true, true, true, true]);
4083+
['Select All', '(Blanks)', '0', '20', '100', '127', '254', '702', '1,000'],
4084+
[true, true, true, true, true, true, true, true, true]);
40854085

40864086
GridFunctions.clickExcelFilterIcon(fix, 'ProductName');
40874087
tick(100);
@@ -4870,33 +4870,27 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
48704870
const column = grid.getColumnByName('AnotherField');
48714871
expect(column.filteringIgnoreCase).toBeTrue();
48724872

4873-
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'AnotherField');
4873+
GridFunctions.clickExcelFilterIcon(fix, 'AnotherField');
48744874
tick(100);
48754875
fix.detectChanges();
48764876

4877-
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4878-
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4879-
4880-
expect(listItems.length).toBe(3, 'incorrect rendered list items count');
4881-
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
4877+
verifyExcelStyleFilterAvailableOptions(fix,
4878+
['Select All', 'a', 'Custom'],
4879+
[true, true, true]);
48824880
}));
48834881

48844882
it('Should not ignore duplicate records when column\'\s filteringIgnoreCase is false', fakeAsync(() => {
48854883
const column = grid.getColumnByName('AnotherField');
48864884
column.filteringIgnoreCase = false;
48874885
expect(column.filteringIgnoreCase).toBeFalse();
48884886

4889-
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'AnotherField');
4887+
GridFunctions.clickExcelFilterIcon(fix, 'AnotherField');
48904888
tick(100);
48914889
fix.detectChanges();
48924890

4893-
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
4894-
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4895-
4896-
expect(listItems.length).toBe(5, 'incorrect rendered list items count');
4897-
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
4898-
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
4899-
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
4891+
verifyExcelStyleFilterAvailableOptions(fix,
4892+
['Select All', 'a', 'Custom', 'custoM', 'custom'],
4893+
[true, true, true, true, true]);
49004894
}));
49014895

49024896
it('Should display "Add to current filter selection" button on typing in input', fakeAsync(() => {
@@ -5269,6 +5263,53 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
52695263
expect(listItems[2].innerText).toBe('No', 'incorrect list item label');
52705264
expect(listItems[3].innerText).toBe('Yes', 'incorrect list item label');
52715265
}));
5266+
5267+
it('Should sort items in excel style search correctly', fakeAsync(() => {
5268+
const data = [
5269+
{
5270+
Downloads: 254,
5271+
ID: 1,
5272+
ProductName: 'Ignite UI for JavaScript',
5273+
ReleaseDate: null,
5274+
ReleaseDateTime: null,
5275+
ReleaseTime: new Date(2010, 4, 27, 23, 0, 0),
5276+
Released: false,
5277+
AnotherField: 'BWord'
5278+
},
5279+
{
5280+
Downloads: 127,
5281+
ID: 2,
5282+
ProductName: 'NetAdvantage',
5283+
ReleaseDate: null,
5284+
ReleaseDateTime: null,
5285+
ReleaseTime: new Date(2021, 4, 27, 1, 0, 0),
5286+
Released: true,
5287+
AnotherField: 'bWord'
5288+
},
5289+
{
5290+
Downloads: 20,
5291+
ID: 3,
5292+
ProductName: 'Ignite UI for Angular',
5293+
ReleaseDate: null,
5294+
ReleaseDateTime: null,
5295+
ReleaseTime: new Date(2015, 4, 27, 12, 0, 0),
5296+
Released: null,
5297+
AnotherField: 'aWord'
5298+
}
5299+
];
5300+
fix.componentInstance.data = data;
5301+
fix.detectChanges();
5302+
5303+
// Open excel style custom filtering dialog for string column
5304+
GridFunctions.clickExcelFilterIcon(fix, 'AnotherField');
5305+
tick(100);
5306+
fix.detectChanges();
5307+
5308+
// Verify items order is case INsensitive
5309+
verifyExcelStyleFilterAvailableOptions(fix,
5310+
['Select All', 'aWord', 'BWord'],
5311+
[true, true, true]);
5312+
}));
52725313
});
52735314

52745315
describe('Templates: ', () => {
@@ -5743,7 +5784,6 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
57435784

57445785
tick(1050);
57455786
fix.detectChanges();
5746-
57475787
}));
57485788

57495789
it('Done callback should be executed only once per column', fakeAsync(() => {
@@ -6321,6 +6361,7 @@ const verifyExcelStyleFilterAvailableOptions = (fix, labels: string[], checked:
63216361
const labelElements: any[] = Array.from(GridFunctions.getExcelStyleSearchComponentListItems(fix, excelMenu));
63226362
const checkboxElements: any[] = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix, excelMenu));
63236363

6364+
expect(labelElements.length).toBe(labels.length, 'incorrect rendered list items count');
63246365
expect(labelElements.length).toBeGreaterThan(2);
63256366
expect(checkboxElements.length).toBeGreaterThan(2);
63266367
labels.forEach((l, index) => {

projects/igniteui-angular/src/lib/grids/grid/grid.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,9 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
920920
public onChipClicked(event: IChipClickEventArgs) {
921921
const sortingExpr = this.sortingExpressions;
922922
const columnExpr = sortingExpr.find((expr) => expr.fieldName === event.owner.id);
923+
const groupExpr = this.groupingExpressions.find((expr) => expr.fieldName === event.owner.id);
923924
columnExpr.dir = 3 - columnExpr.dir;
925+
groupExpr.dir = columnExpr.dir;
924926
this.sort(columnExpr);
925927
this.notifyChanges();
926928
}

0 commit comments

Comments
 (0)