Skip to content

Commit a46608f

Browse files
committed
feat(igxTreeGrid): Implements disabled row #6640
1 parent 016e8df commit a46608f

8 files changed

+37
-20
lines changed

projects/igniteui-angular/src/lib/grids/common/row.interface.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ export interface RowType {
55
checkboxElement: IgxCheckboxComponent;
66
rowID: any;
77
rowData: any;
8+
disabled: boolean;
89
rowSelectable: boolean;
910
index: number;
1011
gridID: string;
1112
added: boolean;
13+
pinned: boolean;
1214
deleted: boolean;
1315
selected: boolean;
1416
focused: boolean;

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -5784,7 +5784,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
57845784
this.lastSearchInfo = { ...this.lastSearchInfo };
57855785

57865786
if (scroll !== false) {
5787-
this.scrollTo(matchInfo.row, matchInfo.column);
5787+
matchInfo.row.ghostRec !== undefined ? this.scrollTo(matchInfo.row.recordData, matchInfo.column) :
5788+
this.scrollTo(matchInfo.row, matchInfo.column);
57885789
}
57895790

57905791
IgxTextHighlightDirective.setActiveHighlight(this.id, {
@@ -5931,7 +5932,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
59315932
const datePipe = new IgxDatePipeComponent(this.locale);
59325933
data.forEach((dataRow) => {
59335934
const ghostRec = dataRow.ghostRec !== undefined;
5934-
const data = { ...dataRow };
5935+
const dataRowRec = { ...dataRow };
59355936
dataRow = ghostRec ? dataRow.recordData : dataRow;
59365937
columnItems.forEach((c) => {
59375938
const value = c.formatter ? c.formatter(dataRow[c.field]) :
@@ -5944,7 +5945,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
59445945
if (exactMatch) {
59455946
if (searchValue === searchText) {
59465947
this.lastSearchInfo.matchInfoCache.push({
5947-
row: data,
5948+
row: dataRowRec,
59485949
column: c.field,
59495950
index: 0,
59505951
});

projects/igniteui-angular/src/lib/grids/row.directive.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
5858
@Input()
5959
public index: number;
6060

61+
/**
62+
* Sets whether this specific row has disabled functionality for editing and row selection.
63+
* Default value is `false`.
64+
* ```typescript
65+
* this.grid.selectedRows[0].pinned = true;
66+
* ```
67+
*/
68+
@Input()
69+
@HostBinding('class.igx-grid__tr--disabled')
70+
public disabled = false;
71+
6172
/**
6273
* Gets whether the row is pinned.
6374
* ```typescript
@@ -309,7 +320,7 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
309320
*/
310321
@HostListener('click', ['$event'])
311322
public onClick(event: MouseEvent) {
312-
if (this.grid.rowSelection === 'none' || this.deleted) { return; }
323+
if (this.grid.rowSelection === 'none' || this.deleted || this.disabled) { return; }
313324
if (event.shiftKey && this.grid.rowSelection === 'multiple') {
314325
this.selectionService.selectMultipleRows(this.rowID, this.rowData, event);
315326
return;
@@ -321,6 +332,7 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
321332
* @hidden
322333
*/
323334
public onRowSelectorClick(event) {
335+
if (this.disabled) { return; }
324336
event.stopPropagation();
325337
if (event.shiftKey && this.grid.rowSelection === 'multiple') {
326338
this.selectionService.selectMultipleRows(this.rowID, this.rowData, event);

projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.html

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ng-template #defaultCell>
22
<div igxTextHighlight style="pointer-events: none" [cssClass]="highlightClass" [activeCssClass]="activeHighlightClass" [groupName]="gridID"
33
[value]="formatter ? formatter(value) : column.dataType === 'number' ? (value | igxdecimal: grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value"
4-
[row]="row.treeRow.data" [column]="this.column.field" [containerClass]="'igx-grid__td-text'"
4+
[row]="rowData" [column]="this.column.field" [containerClass]="'igx-grid__td-text'"
55
class="igx-grid__td-text">{{ formatter ? formatter(value) : column.dataType === 'number' ? (value | igxdecimal:
66
grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value }}</div>
77
</ng-template>
@@ -36,13 +36,7 @@
3636
(click)="toggle($event)" (focus)="onIndicatorFocus()" tabindex="-1">
3737
<ng-container *ngTemplateOutlet="iconTemplate; context: { $implicit: this }">
3838
</ng-container>
39-
<!-- <igx-chip [hidden]="!row.pinnedBodyInstance"
40-
draggable="false"
41-
disabled="true"
42-
displayDensity="cosy"
43-
#pinnedIndicator>
44-
Pinned
45-
</igx-chip> -->
39+
<igx-chip *ngIf="displayPinnedChip" class="igx-grid__td--pinned-chip" [disabled]="true" [displayDensity]="'compact'">Pinned</igx-chip>
4640
</div>
4741
<div *ngIf="isLoading"
4842
(dblclick)="onLoadingDblClick($event)"

projects/igniteui-angular/src/lib/grids/tree-grid/tree-cell.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,11 @@ export class IgxTreeGridCellComponent extends IgxGridExpandableCellComponent {
7070
public onLoadingDblClick(event: Event) {
7171
event.stopPropagation();
7272
}
73+
74+
/**
75+
* @hidden
76+
*/
77+
public get displayPinnedChip() {
78+
return this.row.pinned && this.row.disabled && this.visibleColumnIndex === 0 && !(this.column as any).cellTemplate;
79+
}
7380
}

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-row.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[class.igx-grid__td--number]="col.dataType === 'number'"
2222
[ngClass]="col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex"
2323
[ngStyle]="col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex"
24-
[editMode]="col.editable && crudService.isInEditMode(index, col.index)"
24+
[editMode]="col.editable && crudService.isInEditMode(index, col.index) && !disabled"
2525
[column]="col"
2626
[formatter]="col.formatter"
2727
[row]="this"
@@ -47,7 +47,7 @@
4747
[level]="treeRow.level"
4848
[expanded]="treeRow.expanded"
4949
[showIndicator]="showIndicator"
50-
[editMode]="col.editable && crudService.isInEditMode(index, col.index)"
50+
[editMode]="col.editable && crudService.isInEditMode(index, col.index) && !disabled"
5151
[column]="col"
5252
[formatter]="col.formatter"
5353
[row]="this"
@@ -75,7 +75,7 @@
7575
<igx-checkbox
7676
[readonly]="true"
7777
[checked]="selected"
78-
[disabled]="deleted"
78+
[disabled]="deleted || disabled"
7979
disableRipple="true"
8080
[disableTransitions]="grid.disableTransitions"
8181
[aria-label]="rowCheckboxAriaLabel">

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
</ng-template>
116116
</ng-template>
117117
<ng-container *ngTemplateOutlet="hasPinnedRecords && !isRowPinningToTop ? pinnedRecordsTemplate : null"></ng-container>
118-
<ng-template #record_template let-rowIndex="index" let-rowData>
119-
<igx-tree-grid-row [gridID]="id" [index]="rowIndex" [treeRow]="rowData" #row>
118+
<ng-template #record_template let-rowIndex="index" let-disabledRow="disabled" let-rowData>
119+
<igx-tree-grid-row [gridID]="id" [index]="rowIndex" [treeRow]="rowData" [disabled]="disabledRow" #row>
120120
</igx-tree-grid-row>
121121
</ng-template>
122122
<ng-template #summary_template let-rowIndex="index" let-rowData>

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
378378
/**
379379
* @hidden @internal
380380
*/
381-
private flattenTreeGridRecords(records: ITreeGridRecord[], flatData: any[]) {
381+
private flattenTreeGridRecords(records: any[], flatData: any[]) {
382382
if (records && records.length) {
383383
for (const record of records) {
384-
(this.isGhostRecord(record)) ? flatData.push(record.data.recordData) : flatData.push(record.data);
384+
(this.isGhostRecord(record)) ? flatData.push(record.recordData) : flatData.push(record);
385385
this.flattenTreeGridRecords(record.children, flatData);
386386
}
387387
}
@@ -638,7 +638,8 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
638638
return {
639639
$implicit: rowData,
640640
index: rowIndex,
641-
templateID: this.isSummaryRow(rowData) ? 'summaryRow' : 'dataRow'
641+
templateID: this.isSummaryRow(rowData) ? 'summaryRow' : 'dataRow',
642+
disabled: this.isGhostRecord(rowData.data)
642643
};
643644
}
644645

0 commit comments

Comments
 (0)