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 @@ -26,7 +26,7 @@ import { ISortingExpression, SortingDirection } from '../../data-operations/sort
import { GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec';
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
import { IgxPaginatorComponent, IgxPaginatorContentDirective } from '../../paginator/paginator.component';
import { IGridRowEventArgs, IgxGridFooterComponent, IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../public_api';
import { IGridRowEventArgs, IgxColumnGroupComponent, IgxGridFooterComponent, IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../public_api';
import { getComponentSize } from '../../core/utils';


Expand Down Expand Up @@ -1896,6 +1896,20 @@ describe('IgxGrid Component Tests #grid', () => {

expect(calcWidth).not.toBe(80);
});

it('should correctly autosize column headers inside column groups.', async () => {
const fix = TestBed.createComponent(IgxGridColumnHeaderInGroupAutoSizeComponent);
const grid = fix.componentInstance.grid;
grid.data = [{field1: "Test"}];

//waiting for reqeustAnimationFrame to finish
fix.detectChanges();
await wait(17);
fix.detectChanges();

const calcWidth = parseInt(grid.getColumnByName("field1").calcWidth);
expect(calcWidth).toBe(126);
});
});

describe('IgxGrid - API methods', () => {
Expand Down Expand Up @@ -2962,6 +2976,36 @@ export class IgxGridColumnHeaderAutoSizeComponent {

}

@Component({
template: `
<igx-grid #grid>
<igx-column-group>
<igx-column
field="field1"
header="Field 1 Header"
width="auto"
></igx-column>
<igx-column
field="field2"
header="Field 2 Header"
width="auto"
></igx-column>
<igx-column
field="field3"
header="Field 3 Header"
width="auto"
></igx-column>
</igx-column-group>
</igx-grid>`,
standalone: true,
imports: [IgxGridComponent, IgxColumnComponent, IgxColumnGroupComponent]

})
export class IgxGridColumnHeaderInGroupAutoSizeComponent {
@ViewChild('grid', { read: IgxGridComponent, static: true })
public grid: IgxGridComponent;
}

@Component({
template: `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
<igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
[ngClass]="child.headerGroupClasses"
[ngStyle]="child.headerGroupStyles | igxHeaderGroupStyle:child:grid.pipeTrigger"
[column]="child"
[style.min-width]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
[style.flex-basis]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
[style.min-width]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
[style.flex-basis]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
</igx-grid-header-group>
</ng-container>
</div>
Expand Down