Skip to content

Commit 3c88172

Browse files
Martin DragnevMartin Dragnev
authored andcommitted
fix(igxGrid): Parse minWidth property so that can be set correctly #7209
1 parent 7e00c4b commit 3c88172

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
@@ -432,7 +432,7 @@ export class IgxColumnComponent implements AfterContentInit {
432432
* let columnMaxWidth = this.column.width;
433433
* ```
434434
* ```html
435-
* <igx-column [maxWidth] = "'75%'"></igx-column>
435+
* <igx-column [maxWidth] = "'150px'"></igx-column>
436436
* ```
437437
* @memberof IgxColumnComponent
438438
*/
@@ -446,7 +446,7 @@ export class IgxColumnComponent implements AfterContentInit {
446446
* let columnMinWidth = this.column.minWidth;
447447
* ```
448448
* ```html
449-
* <igx-column [minWidth] = "'15%'"></igx-column>
449+
* <igx-column [minWidth] = "'100px'"></igx-column>
450450
* ```
451451
* @memberof IgxColumnComponent
452452
*/
@@ -1736,7 +1736,6 @@ export class IgxColumnComponent implements AfterContentInit {
17361736
*/
17371737
public autosize() {
17381738
if (!this.columnGroup) {
1739-
17401739
this.width = this.getLargestCellWidth();
17411740
this.grid.reflow();
17421741
}

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
@@ -699,6 +699,23 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
699699
await wait(16);
700700
});
701701

702+
fit('should autosize column when minWidth is set.', async() => {
703+
const fixture = TestBed.createComponent(LargePinnedColGridComponent);
704+
fixture.detectChanges();
705+
706+
const column = fixture.componentInstance.grid.columnList.filter(c => c.field === 'ID')[0];
707+
column.minWidth = '70px';
708+
expect(column.minWidth).toEqual('70px');
709+
710+
column.autosize();
711+
fixture.detectChanges();
712+
713+
expect(column.width).toEqual('63px');
714+
715+
// height/width setter rAF
716+
await wait(16);
717+
});
718+
702719
it('should size headers correctly when column width is below the allowed minimum.', () => {
703720
const fixture = TestBed.createComponent(ColGridComponent);
704721
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)