Skip to content

Commit 1861fd8

Browse files
authored
Merge pull request #7038 from IgniteUI/nrobakova/columnSelection-input
Add columnSelection input
2 parents 7ecd158 + 37f7a52 commit 1861fd8

File tree

13 files changed

+483
-206
lines changed

13 files changed

+483
-206
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ All notable changes for each version of this project will be documented in this
3333
public pinningConfiguration: IPinningConfig = { columns: ColumnPinningPosition.End };
3434
```
3535
- Added functionality for column selection.
36+
- `columnSelection` property has been added. It accepts GridSelection mode enumeration. Grid selection mode could be none, single or multiple.
3637
- `selected` property has been added to the IgxColumnComponent; Allows you to set whether the column is selected.
3738
- `selectable` property has been added to the IgxColumnComponent; Allows you to set whether the column is selectable.
3839
- `onColumnSelectionChange` event is added for the `IgxGrid`. It is emitted when the column selection is changed.

projects/igniteui-angular/src/lib/grids/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Below is the list of all inputs that the developers may set to configure the gri
211211
|`locale`| string | Determines the locale of the grid. Default value is `en`. |
212212
| `isLoading` | bool | Sets if the grid is waiting for data - default value false. |
213213
| `rowDraggable` | bool | Sets if the grid rows can be dragged |
214+
| `columnSelection` | GridSelectionMode | Sets if the grid columns can be selected |
214215

215216
### Outputs
216217

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<header class="igx-excel-filter__menu-header">
6969
<h4>{{ column.header || column.field }}</h4>
7070
<div *ngIf="grid.displayDensity!=='comfortable'" class="igx-excel-filter__menu-header-actions">
71-
<button *ngIf="column.selectable" igxButton="icon"
71+
<button *ngIf="columnSelectable()" igxButton="icon"
7272
[displayDensity]="grid.displayDensity" (click)="onSelect()"
7373
tabindex="0" [ngClass]='selectedClass()'>
7474
<igx-icon fontSet="material">done</igx-icon>
@@ -108,7 +108,7 @@ <h4>{{ column.header || column.field }}</h4>
108108
<ng-container *ngTemplateOutlet="movingTemplate"></ng-container>
109109
</div>
110110

111-
<div *ngIf="column.selectable && grid.displayDensity==='comfortable'">
111+
<div *ngIf="columnSelectable() && grid.displayDensity==='comfortable'">
112112
<ng-container *ngTemplateOutlet="selectingTemplate"></ng-container>
113113
</div>
114114

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { ISelectionEventArgs, IgxDropDownComponent } from '../../../drop-down';
4040
import { IgxColumnComponent } from '../../columns/column.component';
4141
import { IgxGridBaseDirective } from '../../grid-base.directive';
4242
import { DisplayDensity } from '../../../core/density';
43+
import { GridSelectionMode } from '../../common/enums';
4344

4445
/**
4546
* @hidden
@@ -436,13 +437,20 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
436437
*/
437438
public onSelect() {
438439
if (!this.column.selected) {
439-
this.grid.selectionService.selectColumn(this.column.field);
440+
this.grid.selectionService.selectColumn(this.column.field, this.grid.columnSelection === GridSelectionMode.single);
440441
} else {
441442
this.grid.selectionService.deselectColumn(this.column.field);
442443
}
443444
this.grid.notifyChanges();
444445
}
445446

447+
/**
448+
* @hidden @internal
449+
*/
450+
public columnSelectable() {
451+
return this.grid.columnSelection !== GridSelectionMode.none && this.column.selectable;
452+
}
453+
446454
/**
447455
* @hidden @internal
448456
*/

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,26 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
23352335
}
23362336
}
23372337

2338+
/**
2339+
* Gets/Sets column selection mode
2340+
* @remarks
2341+
* By default the row selection mode is none
2342+
* @param selectionMode: GridSelectionMode
2343+
*/
2344+
@WatchChanges()
2345+
@Input()
2346+
get columnSelection() {
2347+
return this._columnSelectionMode;
2348+
}
2349+
2350+
set columnSelection(selectionMode: GridSelectionMode) {
2351+
this._columnSelectionMode = selectionMode;
2352+
if (this.gridAPI.grid) {
2353+
this.selectionService.clearAllSelectedColumns();
2354+
this.notifyChanges(true);
2355+
}
2356+
}
2357+
23382358
/**
23392359
* @hidden @internal
23402360
*/
@@ -2542,6 +2562,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
25422562
private _summaryCalculationMode = GridSummaryCalculationMode.rootAndChildLevels;
25432563
private _cellSelectionMode = GridSelectionMode.multiple;
25442564
private _rowSelectionMode = GridSelectionMode.none;
2565+
private _columnSelectionMode = GridSelectionMode.none;
25452566

25462567
private rowEditPositioningStrategy = new RowEditPositionStrategy({
25472568
horizontalDirection: HorizontalAlignment.Right,

0 commit comments

Comments
 (0)