Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4937,7 +4937,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
* ```
*/
public get hasSummarizedColumns(): boolean {
return this.summaryService.hasSummarizedColumns;
const summarizedColumns = this.columnList.filter(col => col.hasSummary && !col.hidden);
return summarizedColumns.length > 0;
}

/**
Expand Down
31 changes: 28 additions & 3 deletions projects/igniteui-angular/src/lib/grids/state.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ describe('IgxGridState - input properties #grid', () => {
expect(grid.pinnedRows[0].key).toBe(1);
expect(grid.pinnedRows[1].key).toBe(3);
});

it('setState should correctly restore grid moving state from string', () => {
const fix = TestBed.createComponent(IgxGridStateComponent);
fix.detectChanges();
Expand All @@ -460,7 +460,7 @@ describe('IgxGridState - input properties #grid', () => {
expect(grid.moving).toBeFalsy();
gridState = state.getState(true, 'moving');
expect(gridState).toBe(movingState);

});

it('setState should correctly restore grid moving state from object', () => {
Expand All @@ -470,7 +470,7 @@ describe('IgxGridState - input properties #grid', () => {
const state = fix.componentInstance.state;
const movingState = '{"moving":false}';
const initialState = '{"moving":true}';
const movingStateObject = JSON.parse(movingState);
const movingStateObject = JSON.parse(movingState);

let gridState = state.getState(true, 'moving');
expect(gridState).toBe(initialState);
Expand Down Expand Up @@ -590,6 +590,31 @@ describe('IgxGridState - input properties #grid', () => {
gridState = state.getState(true, 'expansion');
expect(gridState).toBe(expansionState);
});

// fit('createExpressionsTreeFromObject should return null when columns are still not resolved', () => {
// const fix = TestBed.createComponent(IgxGridStateComponent);
// fix.detectChanges();
// fix.componentInstance.ngOnInit();
// fix.detectChanges();
// const grid = fix.componentInstance.grid;
// // grid.columnList = new QueryList<IgxColumnComponent>();
// const state = fix.componentInstance.state;
// // eslint-disable-next-line max-len
//
// const advFilteringState = '{"advancedFiltering":{"filteringOperands":[{"fieldName":"InStock","condition":{"name":"true","isUnary":true,"iconName":"is-true"},"searchVal":null,"ignoreCase":true},{"fieldName":"ProductID","condition":{"name":"greaterThan","isUnary":false,"iconName":"greater-than"},"searchVal":"3","ignoreCase":true}],"operator":0,"type":1}}';
// const initialState = '{"advancedFiltering":{}}';
// const advFilteringStateObject = JSON.parse(advFilteringState);
//
// let gridState = state.getState(true, 'advancedFiltering');
// expect(gridState).toBe(initialState);
//
// state.setState(advFilteringStateObject);
// gridState = state.getState(false, 'advancedFiltering') as IGridState;
//
// let areColumnsResolved = grid.columnList.length > 0 || !!gridState.columns
//
// expect(areColumnsResolved).toBe(false);
// });
});

class HelperFunctions {
Expand Down
4 changes: 3 additions & 1 deletion projects/igniteui-angular/src/lib/grids/state.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,10 @@ export class IgxGridStateDirective {
let dataType: string;
if (this.currGrid.columnList.length > 0) {
dataType = this.currGrid.columnList.find(c => c.field === expr.fieldName).dataType;
} else {
} else if (this.state.columns) {
dataType = this.state.columns.find(c => c.field === expr.fieldName).dataType;
} else {
return null;
}
// when ESF, values are stored in Set.
// First those values are converted to an array before returning string in the stringifyCallback
Expand Down