Skip to content

Commit cc68206

Browse files
authored
Merge pull request #7293 from IgniteUI/mdragnev/fix-7209-9.0.x
fix(igxGrid): Parse minWidth property so that can be set correctly
2 parents f24dae0 + 9638b42 commit cc68206

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class IgxColumnComponent implements AfterContentInit {
376376
* let columnMaxWidth = this.column.width;
377377
* ```
378378
* ```html
379-
* <igx-column [maxWidth] = "'75%'"></igx-column>
379+
* <igx-column [maxWidth] = "'150px'"></igx-column>
380380
* ```
381381
* @memberof IgxColumnComponent
382382
*/
@@ -390,7 +390,7 @@ export class IgxColumnComponent implements AfterContentInit {
390390
* let columnMinWidth = this.column.minWidth;
391391
* ```
392392
* ```html
393-
* <igx-column [minWidth] = "'15%'"></igx-column>
393+
* <igx-column [minWidth] = "'100px'"></igx-column>
394394
* ```
395395
* @memberof IgxColumnComponent
396396
*/
@@ -1669,7 +1669,6 @@ export class IgxColumnComponent implements AfterContentInit {
16691669
*/
16701670
public autosize() {
16711671
if (!this.columnGroup) {
1672-
16731672
this.width = this.getLargestCellWidth();
16741673
this.grid.reflow();
16751674
}

projects/igniteui-angular/src/lib/grids/grid/column-resizing.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,23 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
695695
await wait(16);
696696
});
697697

698+
it('should autosize column when minWidth is set.', async() => {
699+
const fixture = TestBed.createComponent(LargePinnedColGridComponent);
700+
fixture.detectChanges();
701+
702+
const column = fixture.componentInstance.grid.columnList.filter(c => c.field === 'ID')[0];
703+
column.minWidth = '70px';
704+
expect(column.minWidth).toEqual('70px');
705+
706+
column.autosize();
707+
fixture.detectChanges();
708+
709+
expect(column.width).toEqual('63px');
710+
711+
// height/width setter rAF
712+
await wait(16);
713+
});
714+
698715
it('should size headers correctly when column width is below the allowed minimum.', () => {
699716
const fixture = TestBed.createComponent(ColGridComponent);
700717
fixture.detectChanges();

projects/igniteui-angular/src/lib/grids/resizing/resizing.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class IgxColumnResizingService {
8888
if (this.column.maxWidth && (parseFloat(size) > parseFloat(this.column.maxWidth))) {
8989
this.column.width = parseFloat(this.column.maxWidth) + 'px';
9090
} else if (parseFloat(size) < parseFloat(this.column.minWidth)) {
91-
this.column.width = this.column.minWidth + 'px';
91+
this.column.width = parseFloat(this.column.minWidth) + 'px';
9292
} else {
9393
this.column.width = size;
9494
}

0 commit comments

Comments
 (0)