Skip to content

Implement Row Pinning for igxHierarchicalGrid. #6979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6e25890
feat(igxHiearchicalGrid): Initial implementation of row pinning.
skrustev Mar 25, 2020
47b8af2
feat(igxHierarchicalGrid): Remove hierarchical ghost row and add inst…
skrustev Mar 26, 2020
4f1f30d
feat(igxHierarchicalGrid): Improve ghost row styling.,
skrustev Mar 26, 2020
901a858
fix(rowPinning): Fix issues with styling and reverse navigation chang…
skrustev Mar 27, 2020
aff72cd
chore(*): Replace editable input with disabled input containing logic…
skrustev Mar 31, 2020
57c5955
Merge master into skrastev/hgrid-row-pinning
skrustev Mar 31, 2020
0ed3801
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 1, 2020
197bd53
chore(*): Move disabled styling to grid row. Remove ghostRow input an…
skrustev Apr 1, 2020
afdc785
chore(*): Fix lint in hierarchical grid
skrustev Apr 1, 2020
a6d16c9
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 1, 2020
a5c37d5
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 3, 2020
7272f91
fix(igxGrid): Fix paging calculation with row pinning. Small fixes to…
skrustev Apr 6, 2020
9c71be7
tests(igxHierarchicalGrid): Add tests for hierarchical grid row pinning
skrustev Apr 6, 2020
b3e55d8
chore(*): Merge master into skrastev/hgrid-row-pinning
skrustev Apr 6, 2020
2247f0b
fix(igxGrid): Fix selection range of both unpinned and pinned cells.
skrustev Apr 6, 2020
1fe8264
feat(igxHierarchicalGrid): Move pinned chip to base cell template and…
skrustev Apr 6, 2020
8a51940
chore(*): Fix lint errors.
skrustev Apr 6, 2020
6dd830b
chore(*): Update failing test and fix filterData in hierarchical grid…
skrustev Apr 6, 2020
3d21953
Merge branch 'master' into skrastev/hgrid-row-pinning
kdinev Apr 7, 2020
0e0bf53
chore(*): Fix geting selected data when using bottom row pinning and …
skrustev Apr 7, 2020
0b4b27d
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 7, 2020
5b4deb3
chore(*): Fix additional failing test
skrustev Apr 7, 2020
7843292
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 7, 2020
0395b4f
chore(*): Prettify hierarchical grid tests and fix disabled cell styl…
skrustev Apr 7, 2020
9906ba0
chore(*): Fix hierarchical test lint.
skrustev Apr 7, 2020
7fb99bc
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 8, 2020
043f7f8
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 8, 2020
6cc72fb
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 8, 2020
368bff3
fix(igxCell): Fix cell entering edit mode when disabled with enter/f2.
skrustev Apr 8, 2020
5ab9919
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 9, 2020
ee87527
chore(*): Address comments on styling.
skrustev Apr 10, 2020
e837fb3
Merge master into skrastev/hgrid-row-pinning
skrustev Apr 10, 2020
10b3492
fix(igxGrid): Fix disabled row issues related to merge.
skrustev Apr 10, 2020
b078d76
Merge branch 'master' into skrastev/hgrid-row-pinning
ChronosSF Apr 13, 2020
5b847eb
chore(*): Disable test related to issue.
Apr 13, 2020
ed6f4be
Merge pull request #7119 from IgniteUI/SKrastev/hgrid-row-pinning
MayaKirova Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@
@extend %igx-grid__td--editing !optional;
}

@include e(tr, $m: disabled) {
@extend %igx-grid__tr--disabled !optional;
}

@include e(td, $m: number) {
@extend %grid-cell-number !optional;
}
Expand Down Expand Up @@ -392,6 +396,10 @@
@extend %grid-cell--pinned--column-selected !optional;
}

@include e(td, $m: pinned-chip) {
@extend %grid-cell--pinned-chip !optional;
}

@include e(td-text) {
@extend %grid-cell-text !optional;
}
Expand Down Expand Up @@ -558,6 +566,11 @@
@extend %igx-grid__hierarchical-expander !optional;
}

@include e(hierarchical-expander, $m: empty) {
@extend %igx-grid__hierarchical-expander !optional;
@extend %igx-grid__hierarchical-expander--empty !optional;
}

@include e(hierarchical-expander, $m: header) {
@extend %igx-grid__hierarchical-expander--header !optional;
}
Expand Down Expand Up @@ -673,6 +686,11 @@
@extend %igx-grid__hierarchical-expander--cosy !optional;
}

@include e(hierarchical-expander, $m: empty) {
@extend %igx-grid__hierarchical-expander--cosy !optional;
@extend %igx-grid__hierarchical-expander--empty !optional;
}

@include e(hierarchical-expander, $m: push) {
@extend %igx-grid__hierarchical-expander--push--cosy !optional;
}
Expand All @@ -688,6 +706,10 @@
@extend %igx-grid__tree-cell-cosy--padding-level-#{$i} !optional;
}
}

@include e(td, $m: pinned-chip) {
@extend %grid-cell--pinned-chip--cosy !optional;
}
}

@include m(compact) {
Expand Down Expand Up @@ -772,6 +794,11 @@
@include e(hierarchical-expander) {
@extend %igx-grid__hierarchical-expander--compact !optional;
}

@include e(hierarchical-expander, $m: empty) {
@extend %igx-grid__hierarchical-expander--compact !optional;
@extend %igx-grid__hierarchical-expander--empty !optional;
}

@include e(hierarchical-expander, $m: push) {
@extend %igx-grid__hierarchical-expander--push--compact !optional;
Expand All @@ -788,6 +815,10 @@
@extend %igx-grid__tree-cell-compact--padding-level-#{$i} !optional;
}
}

@include e(td, $m: pinned-chip) {
@extend %grid-cell--pinned-chip--compact !optional;
}
}

@include _excel-filtering-partial();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
/// @param {Color} $cell-selected-background [null] - The selected cell background color.
/// @param {Color} $cell-selected-text-color [null] - The selected cell text color.
/// @param {Color} $cell-editing-background [null] - The background color of the cell being edited.
/// @param {Color} $cell-edited-value-color [null] - The text color of a sell that has been edited.
/// @param {Color} $cell-edited-value-color [null] - The text color of a cell that has been edited.
/// @param {Color} $cell-disabled-color [null] - The text color of a disabled cell.
///
/// @param {Color} $edit-mode-color [null] - The color applied around the row when in editing mode.
/// @param {Color} $edited-row-indicator [null] - The color applied to the edited row indicator line.
Expand Down Expand Up @@ -160,6 +161,7 @@
$cell-selected-text-color: null,
$cell-editing-background: null,
$cell-edited-value-color: null,
$cell-disabled-color: null,

$edit-mode-color: null,
$edited-row-indicator: null,
Expand Down Expand Up @@ -505,6 +507,8 @@
edited-row-indicator: $edited-row-indicator,
cell-edited-value-color: $cell-edited-value-color,

cell-disabled-color: $cell-disabled-color,

resize-line-color: $resize-line-color,

drop-indicator-color: $drop-indicator-color,
Expand Down Expand Up @@ -1352,6 +1356,12 @@
}
}

%igx-grid__tr--disabled {
%grid-cell-text {
color: --var($theme, 'cell-disabled-color');
}
}

%igx-grid__td--editing {
background: --var($theme, 'cell-editing-background') !important;
box-shadow: inset 0 0 0 rem(2px) --var($theme, 'edit-mode-color');
Expand Down Expand Up @@ -1407,6 +1417,17 @@
}
}

%grid-cell--pinned-chip {
margin-#{$right}: rem(12px);
}

%grid-cell--pinned-chip--cosy {
margin-#{$right}: rem(8px);
}

%grid-cell--pinned-chip--compact {
margin-#{$right}: rem(4px);
}

%grid-cell-header {
flex-flow: row nowrap;
Expand Down Expand Up @@ -2495,6 +2516,11 @@
@include if-rtl() {
transform: scaleX(-1);
}

&--empty {
cursor: default;
pointer-events: none;
}
}

%igx-grid__hierarchical-expander--cosy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
/// @prop {Map} edit-mode-color [igx-color: ('secondary', 500)] - The text color in edit mode.
/// @prop {Map} edited-row-indicator [igx-color: ('grays', 400)] - The indicator's color of edited row.
/// @prop {Map} cell-edited-value-color [igx-color: ('grays', 600)] - The color of cell edited value.
/// @prop {Map} cell-disabled-color [igx-color: ('grays', 500)] - The text color of a disabled cell.
/// @prop {Map} resize-line-color [igx-color: ('secondary', 500)] - The table header resize line color.
/// @prop {Map} drop-indicator-color [igx-color: ('secondary', 500)] - The color of the drop indicator.
/// @prop {Map} grouparea-background [igx-color: ('grays', 100), hexrgba: #fff] - The grid group area background color.
Expand Down Expand Up @@ -233,6 +234,10 @@ $_light-grid: extend(
igx-color: ('grays', 600)
),

cell-disabled-color: (
igx-color: ('grays', 500)
),

resize-line-color: (
igx-color: ('secondary', 500)
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<ng-template #defaultCell>
<igx-chip *ngIf="displayPinnedChip" class="igx-grid__td--pinned-chip" [disabled]="true" [displayDensity]="'compact'">Pinned</igx-chip>
<div igxTextHighlight style="pointer-events: none" [cssClass]="highlightClass" [activeCssClass]="activeHighlightClass" [groupName]="gridID"
[value]="formatter ? formatter(value) : column.dataType === 'number' ? (value | igxdecimal: grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value"
[row]="rowData" [column]="this.column.field" [containerClass]="'igx-grid__td-text'"
Expand Down
11 changes: 9 additions & 2 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
*/
@HostBinding('attr.aria-readonly')
get readonly(): boolean {
return !this.column.editable;
return !this.editable;
}

get gridRowSpan(): number {
Expand Down Expand Up @@ -523,7 +523,14 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
* Returns whether the cell is editable.
*/
get editable(): boolean {
return this.column.editable;
return this.column.editable && !this.row.disabled;
}

/**
* @hidden
*/
public get displayPinnedChip() {
return this.row.pinned && this.row.disabled && this.visibleColumnIndex === 0 && !(this.column as any).cellTemplate;
}

@ViewChild('defaultCell', { read: TemplateRef, static: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export interface RowType {
checkboxElement: IgxCheckboxComponent;
rowID: any;
rowData: any;
disabled: boolean;
rowSelectable: boolean;
index: number;
gridID: string;
added: boolean;
pinned: boolean;
deleted: boolean;
selected: boolean;
focused: boolean;
Expand Down
17 changes: 14 additions & 3 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5140,6 +5140,17 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
return this.verticalScrollContainer.igxForOf;
}

/**
* Returns the currently transformed paged/filtered/sorted/grouped pinned data, displayed in the grid.
* @example
* ```typescript
* const pinnedDataView = this.grid.pinnedDataView;
* ```
*/
get pinnedDataView(): any[] {
return this.pinnedRows.map(row => row.rowData);
}

/**
* Get current selection state.
* @example
Expand Down Expand Up @@ -5344,8 +5355,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
columnsArray.forEach((col) => {
if (col) {
const key = headers ? col.header || col.field : col.field;
record[key] = formatters && col.formatter ? col.formatter(source[row][col.field])
: source[row][col.field];
const value = source[row].ghostRecord ? source[row].recordRef[col.field] : source[row][col.field];
record[key] = formatters && col.formatter ? col.formatter(value) : value;
}
});
}
Expand Down Expand Up @@ -5380,7 +5391,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
* If `headers` is enabled, it will use the column header (if any) instead of the column field.
*/
public getSelectedData(formatters = false, headers = false) {
const source = this.dataView;
const source = this.isRowPinningToTop ? [...this.pinnedDataView, ...this.dataView] : [...this.dataView, ...this.pinnedDataView];
return this.extractDataFromSelection(source, formatters, headers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export class IgxGridNavigationService {
break;
case 'enter':
case 'f2':
if (!this.isDataRow(rowIndex)) { break; }
const cell = this.grid.getCellByColumnVisibleIndex(this.activeNode.row, this.activeNode.column);
if (!this.isDataRow(rowIndex) || !cell.editable) { break; }
this.grid.crudService.enterEditMode(cell);
break;
case 'escape':
Expand All @@ -114,8 +114,8 @@ export class IgxGridNavigationService {
case ' ':
case 'spacebar':
case 'space':
if (this.grid.isRowSelectable && this.isDataRow(rowIndex)) {
const rowObj = this.grid.getRowByIndex(this.activeNode.row);
const rowObj = this.grid.getRowByIndex(this.activeNode.row);
if (this.grid.isRowSelectable && this.isDataRow(rowIndex) && !rowObj.disabled) {
rowObj && rowObj.selected ? this.grid.selectionService.deselectRow(rowObj.rowID, event) :
this.grid.selectionService.selectRowById(rowObj.rowID, false, event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
[tabindex]="-1"
[checked]="selected"
[readonly]="true"
[disabled]="deleted"
[disabled]="disabled || deleted"
disableRipple="true"
[disableTransitions]="grid.disableTransitions"
[aria-label]="rowCheckboxAriaLabel">
Expand Down
25 changes: 20 additions & 5 deletions projects/igniteui-angular/src/lib/grids/grid/row-pinning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { IgxGridTransaction } from '../tree-grid';
import { IgxTransactionService } from '../../services';
import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec';
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
import { IgxPaginatorComponent } from '../../paginator/paginator.component';

describe('Row Pinning #grid', () => {
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ';
Expand Down Expand Up @@ -401,26 +402,40 @@ describe('Row Pinning #grid', () => {
grid.paging = true;
grid.perPage = 5;
fix.detectChanges();
let row = grid.getRowByIndex(1);
row.pin();
const paginator = fix.debugElement.query(By.directive(IgxPaginatorComponent));
expect(paginator.componentInstance.totalPages).toEqual(6);

grid.getRowByIndex(1).pin();
fix.detectChanges();

expect(grid.pinnedRows.length).toBe(1);
let pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
expect(pinRowContainer.length).toBe(1);

expect(grid.dataView.length).toBe(4);
expect(paginator.componentInstance.totalPages).toEqual(6);

grid.getRowByIndex(3).pin();
fix.detectChanges();

expect(grid.pinnedRows.length).toBe(2);
pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
expect(pinRowContainer.length).toBe(1);
expect(grid.dataView.length).toBe(3);
expect(paginator.componentInstance.totalPages).toEqual(5);

// unpin
row = grid.getRowByIndex(0);
row.unpin();
grid.getRowByIndex(0).unpin();
fix.detectChanges();

grid.getRowByIndex(0).unpin();
fix.detectChanges();

expect(grid.pinnedRows.length).toBe(0);
pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
expect(pinRowContainer.length).toBe(0);

expect(grid.dataView.length).toBe(5);
expect(paginator.componentInstance.totalPages).toEqual(6);
});

it('should apply sorting to both pinned and unpinned rows.', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IgxGridCellComponent } from '../cell.component';
import { GridBaseAPIService } from '../api.service';
import { ChangeDetectorRef, ElementRef, ChangeDetectionStrategy, Component,
OnInit, HostListener, NgZone } from '@angular/core';
OnInit, HostListener, NgZone, HostBinding } from '@angular/core';
import { IgxHierarchicalGridComponent } from './hierarchical-grid.component';
import { IgxGridSelectionService, IgxGridCRUDService } from '../selection/selection.service';
import { HammerGesturesManager } from '../../core/touch';
Expand All @@ -11,11 +11,10 @@ import { PlatformUtil } from '../../core/utils';
changeDetection: ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
selector: 'igx-hierarchical-grid-cell',
templateUrl: './../cell.component.html',
templateUrl: '../cell.component.html',
providers: [HammerGesturesManager]
})
export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent implements OnInit {

// protected hSelection;
protected _rootGrid;

Expand Down
Loading