Skip to content

Commit 6752d56

Browse files
authored
Merge pull request #13455 from IgniteUI/ddincheva/gridSizingFix--15.1
Fix: IgxGrid: Horizontal scrollbar is displayed when row selection is enabled --15.1.x
2 parents 36c3a29 + 65b83be commit 6752d56

File tree

3 files changed

+48
-17
lines changed

3 files changed

+48
-17
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5487,8 +5487,6 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
54875487
parseInt(this.document.defaultView.getComputedStyle(this.nativeElement).getPropertyValue('width'), 10);
54885488
}
54895489

5490-
computedWidth -= this.featureColumnsWidth();
5491-
54925490
const visibleChildColumns = this.visibleColumns.filter(c => !c.columnGroup);
54935491

54945492

@@ -5524,6 +5522,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
55245522
if (!sumExistingWidths && !columnsToSize) {
55255523
return '0px';
55265524
}
5525+
computedWidth -= this.featureColumnsWidth();
55275526

55285527
const columnWidth = Math.floor(!Number.isFinite(sumExistingWidths) ?
55295528
Math.max(computedWidth / columnsToSize, this.minColumnWidth) :
@@ -6348,7 +6347,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
63486347
}
63496348

63506349
/**
6351-
* Finishes the row transactions on the current row and returns whether the grid editing was canceled.
6350+
* Finishes the row transactions on the current row and returns whether the grid editing was canceled.
63526351
*
63536352
* @remarks
63546353
* If `commit === true`, passes them from the pending state to the data (or transaction service)
@@ -6882,8 +6881,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
68826881
sizing process which of course, uses values from the caches, thus resulting
68836882
in a broken layout.
68846883
*/
6885-
this.resetCaches(recalcFeatureWidth);
68866884
this.cdr.detectChanges();
6885+
this.resetCaches(recalcFeatureWidth);
6886+
68876887
const hasScroll = this.hasVerticalScroll();
68886888
this.calculateGridWidth();
68896889
this.resetCaches(recalcFeatureWidth);

src/app/grid-selection/grid-selection.sample.html

+36-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<div class="sample-container">
22
<div class="sample-actions">
3+
<button (click)="log('')">LOG</button>
34
<igx-switch [(ngModel)]="grid1.hideRowSelectors">Hide row selectors</igx-switch>
45

56
<button igxButton="raised" [igxToggleAction]="dropDownComfortable" [igxDropDownItemNavigation]="dropDownComfortable" displayDensity="comfortable">Cell Selection: {{grid1.cellSelection}}</button>
@@ -16,17 +17,41 @@
1617
</igx-drop-down>
1718
</div>
1819

19-
<igx-grid #grid1 [data]="remote | async" [allowFiltering]="true" [primaryKey]="'ProductID'" (selected)="handleRowSelection()"
20-
[width]="'800px'" [height]="'600px'" (rowSelectionChanging)="log($event)">
21-
<igx-column [field]="'ProductID'" [editable]="true" [width]="'80%'"></igx-column>
22-
<igx-column [field]="'ProductName'"></igx-column>
23-
<igx-column [field]="'UnitsInStock'"></igx-column>
24-
25-
<!-- <ng-template igxRowSelector let-rowContext>
26-
<span class="rowNumberChild">{{ rowContext.key }}</span>
27-
<igx-checkbox (click)="handleRowSelectorClick(rowContext)" [checked]="rowContext.selected">
28-
</igx-checkbox>
29-
</ng-template> -->
20+
<igx-grid #grid1 [data]="data" [allowFiltering]="true" [primaryKey]="'ProductID'" (selected)="handleRowSelection()" [rowSelection]="'single'"
21+
[height]="'550px'" width="100%" (rowSelectionChanging)="log($event)">
22+
<igx-column
23+
[field]="'ProductName'"
24+
dataType="string"
25+
[sortable]="true"
26+
></igx-column>
27+
<igx-column
28+
[field]="'SupplierID'"
29+
dataType="string"
30+
[sortable]="true"
31+
></igx-column>
32+
<igx-column
33+
[field]="'OrderDate'"
34+
dataType="date"
35+
[sortable]="true"
36+
></igx-column>
37+
<igx-column
38+
[field]="'ProductID'"
39+
dataType="number"
40+
[sortable]="true"
41+
width="15%"
42+
></igx-column>
43+
<igx-column
44+
[field]="'UnitsInStock'"
45+
dataType="number"
46+
[sortable]="true"
47+
width="15%"
48+
></igx-column>
49+
<igx-column
50+
[field]="'Discontinued'"
51+
dataType="boolean"
52+
[sortable]="true"
53+
width="15%"
54+
></igx-column>
3055
</igx-grid>
3156

3257
<div class="sample-actions">

src/app/grid-selection/grid-selection.sample.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AfterViewInit, ChangeDetectorRef, Component, ViewChild } from '@angular
22
import { Observable } from 'rxjs';
33
import { IgxGridComponent } from 'igniteui-angular';
44
import { RemoteService } from '../shared/remote.service';
5+
import { data } from '../shared/data';
56

67
@Component({
78
selector: 'app-grid-selection-sample',
@@ -15,14 +16,16 @@ export class GridSelectionComponent implements AfterViewInit {
1516
public remote: Observable<any[]>;
1617
public selection = true;
1718
public selectionModes = ['none', 'single', 'multiple'];
19+
public data = [];
1820

1921
constructor(private remoteService: RemoteService, private cdr: ChangeDetectorRef) {
2022
this.remoteService.urlBuilder = () => this.remoteService.url;
2123
}
2224

2325
public ngAfterViewInit() {
24-
this.remote = this.remoteService.remoteData;
25-
this.remoteService.getData(this.grid1.data);
26+
/* this.remote = this.remoteService.remoteData;
27+
this.remoteService.getData(this.grid1.data); */
28+
this.data = data;
2629
this.cdr.detectChanges();
2730
}
2831

@@ -78,6 +81,9 @@ export class GridSelectionComponent implements AfterViewInit {
7881

7982
public log(args) {
8083
console.log(args);
84+
console.log('WIDTH ', this.grid1.calcWidth);
85+
console.log((this.grid1 as any)._columns.map(c => c.calcWidth));
86+
console.log('UnpinnedWidth: ', this.grid1.unpinnedWidth);
8187
}
8288

8389
public callSelectAll() {

0 commit comments

Comments
 (0)