Skip to content

Commit aff72cd

Browse files
committed
chore(*): Replace editable input with disabled input containing logic for preveinting row selection as wel. Update hierarchical grid.
1 parent 901a858 commit aff72cd

File tree

9 files changed

+27
-38
lines changed

9 files changed

+27
-38
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
524524
* Returns whether the cell is editable.
525525
*/
526526
get editable(): boolean {
527-
return (this.column.editable && (this.row.editable === undefined || this.row.editable)) || this.row.editable;
527+
return (this.column.editable && !this.row.disabled) || !this.row.disabled;
528528
}
529529

530530
/**

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface RowType {
55
checkboxElement: IgxCheckboxComponent;
66
rowID: any;
77
rowData: any;
8-
editable: boolean;
8+
disabled: boolean;
99
rowSelectable: boolean;
1010
index: number;
1111
gridID: string;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<igx-checkbox
7777
[checked]="selected"
7878
[readonly]="true"
79-
[disabled]="deleted"
79+
[disabled]="disabled || deleted"
8080
disableRipple="true"
8181
[disableTransitions]="grid.disableTransitions"
8282
[aria-label]="rowCheckboxAriaLabel">

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
495495
*/
496496
public isHierarchicalRecord(record: any): boolean {
497497
if (this.isGhostRecord(record)) {
498-
record = record.recordData;
498+
record = record.recordRef;
499499
}
500500
return this.childLayoutList.length !== 0 && record[this.childLayoutList.first.key];
501501
}
@@ -509,7 +509,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
509509
}
510510

511511
public isGhostRecord(record: any): boolean {
512-
return record.ghostRec !== undefined;
512+
return record.ghostRecord !== undefined;
513513
}
514514

515515
/**
@@ -549,7 +549,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
549549
}
550550
} else {
551551
return {
552-
$implicit: this.isGhostRecord(rowData) ? rowData.recordData : rowData,
552+
$implicit: this.isGhostRecord(rowData) ? rowData.recordRef : rowData,
553553
templateID: 'dataRow',
554554
index: this.getRowIndex(rowIndex, pinned),
555555
ghostRow: this.isGhostRecord(rowData)

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.pipes.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export class IgxGridHierarchicalPipe implements PipeTransform {
3737

3838
data.forEach((v: any) => {
3939
result.push(v);
40-
if (v.ghostRec !== undefined) {
41-
v = v.recordData;
40+
if (v.ghostRecord !== undefined) {
41+
v = v.recordRef;
4242
}
4343

4444
const childGridsData = {};
@@ -101,7 +101,7 @@ export class IgxGridHierarchicalRowPinning implements PipeTransform {
101101
}
102102

103103
const result = collection.map((value) => {
104-
return grid.isRecordPinned(value) ? { recordData: value, ghostRec: true} : value;
104+
return grid.isRecordPinned(value) ? { recordRef: value, ghostRecord: true} : value;
105105
});
106106
return result;
107107
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
[readonly]="true"
7272
[checked]="selected"
7373
disableRipple="true"
74-
[disabled]="ghostRow || deleted"
74+
[disabled]="disabled || deleted"
7575
[disableTransitions]="grid.disableTransitions"
7676
[aria-label]="rowCheckboxAriaLabel">
7777
</igx-checkbox>

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

+1-22
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ export class IgxHierarchicalRowComponent extends IgxRowDirective<IgxHierarchical
3131
* @hidden
3232
*/
3333
@Input()
34-
/**
35-
* @hidden
36-
*/
3734
@HostBinding('class.igx-grid__tr--ghost-copy')
3835
public set ghostRow(value: boolean) {
39-
this.editable = !value;
36+
this.disabled = value;
4037
this._ghostRow = value;
4138
}
4239

@@ -193,22 +190,4 @@ export class IgxHierarchicalRowComponent extends IgxRowDirective<IgxHierarchical
193190
g.endEdit();
194191
}});
195192
}
196-
197-
/**
198-
* @hidden
199-
* @internal
200-
*/
201-
@HostListener('click', ['$event'])
202-
public onClick(event: MouseEvent) {
203-
if (this.ghostRow) { return; }
204-
super.onClick(event);
205-
}
206-
207-
/**
208-
* @hidden
209-
*/
210-
public onRowSelectorClick(event) {
211-
if (this.ghostRow) { return; }
212-
super.onRowSelectorClick(event);
213-
}
214193
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
6060
public index: number;
6161

6262
/**
63-
* Sets whether this specific row can be editable.
63+
* Sets whether this specific row has disabled functionality for editing and row selection.
6464
* Default value is `false`.
6565
* ```typescript
6666
* this.grid.selectedRows[0].pinned = true;
6767
* ```
6868
*/
6969
@Input()
70-
public editable: boolean;
70+
public disabled = false;
7171

7272
/**
7373
* Gets whether the row is pinned.
@@ -320,7 +320,7 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
320320
*/
321321
@HostListener('click', ['$event'])
322322
public onClick(event: MouseEvent) {
323-
if (this.grid.rowSelection === 'none' || this.deleted) { return; }
323+
if (this.grid.rowSelection === 'none' || this.deleted || this.disabled) { return; }
324324
if (event.shiftKey && this.grid.rowSelection === 'multiple') {
325325
this.selectionService.selectMultipleRows(this.rowID, this.rowData, event);
326326
return;
@@ -332,6 +332,7 @@ export class IgxRowDirective<T extends IgxGridBaseDirective & GridType> implemen
332332
* @hidden
333333
*/
334334
public onRowSelectorClick(event) {
335+
if (this.disabled) { return; }
335336
event.stopPropagation();
336337
if (event.shiftKey && this.grid.rowSelection === 'multiple') {
337338
this.selectionService.selectMultipleRows(this.rowID, this.rowData, event);

src/app/grid-row-pinning/grid-row-pinning.sample.html

+12-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<igx-switch (change)='onRowChange()' style="padding-left: 10px"> Bottom Row Pinning toggle</igx-switch>
1414
<igx-switch (change)='onChange()' style="padding-left: 10px"> Right Column Pinning toggle</igx-switch>
1515
</div>
16-
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
16+
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [paging]="true" [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
1717
<igx-column width='70px' [filterable]='false'>
1818
<ng-template igxCell let-cell="cell" let-val>
1919
<igx-icon class="pin-icon" (mousedown)="togglePining(cell.row, $event)">
@@ -32,15 +32,24 @@
3232
</igx-grid>
3333
</div>
3434
<div class="sample-column">
35-
<igx-hierarchical-grid [showExpandAll]='true' [data]="hierarchicalData" [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' [columnHiding]='true' [width]="'800px'" [height]="'500px'" [rowSelectable]="true" #hGrid>
35+
<igx-hierarchical-grid #hGrid [width]="'800px'" [height]="'600px'" [paging]="true" [primaryKey]='"ID"' [rowEditable]="true" [allowFiltering]='true'
36+
[showExpandAll]='true' [data]="hierarchicalData" [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' [columnHiding]='true' [rowSelectable]="true" >
37+
<ng-template igxToolbarCustomContent>
38+
<app-grid-search-box [grid]="hGrid" [style.width]="'400px'"></app-grid-search-box>
39+
</ng-template>
3640
<igx-column width='70px' [filterable]='false'>
3741
<ng-template igxCell let-cell="cell" let-val>
3842
<igx-icon class="pin-icon" (mousedown)="togglePining(cell.row, $event)">
3943
{{cell.row.pinned ? 'lock' : 'lock_open'}}
4044
</igx-icon>
4145
</ng-template>
4246
</igx-column>
43-
<igx-column *ngFor="let c of hColumns" [sortable]="true" [field]="c.field" [header]="c.field" [width]="c.width" [pinned]='c.pinned' [groupable]='c.groupable' [editable]="true">
47+
<igx-column width='100px' [filterable]='false'>
48+
<ng-template igxCell let-cell="cell" let-val>
49+
<button (click)="hGrid.deleteRow(cell.cellID.rowID)">Delete</button>
50+
</ng-template>
51+
</igx-column>
52+
<igx-column *ngFor="let c of hColumns" [sortable]="true" [field]="c.field" [header]="c.field" [width]="c.width" [pinned]='c.pinned' [groupable]='c.groupable' >
4453
</igx-column>
4554
<igx-row-island [key]="'childData'" [autoGenerate]="true" [rowSelectable]='true' [allowFiltering]='true' >
4655
<igx-row-island [key]="'childData'" [autoGenerate]="true" [rowSelectable]='true' [allowFiltering]='true'></igx-row-island>

0 commit comments

Comments
 (0)