Skip to content

Commit fd6e77a

Browse files
MKirovaMKirova
authored andcommitted
feat(igxGrid): Persit pinning config.
1 parent 9c42ec1 commit fd6e77a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { GridSelectionRange } from './selection/selection.service';
1212
import { IGroupByExpandState } from '../data-operations/groupby-expand-state.interface';
1313
import { IGroupingState } from '../data-operations/groupby-state.interface';
1414
import { IgxGridComponent } from './grid/grid.component';
15+
import { IPinningConfig } from './common/grid.interface';
1516

1617
export interface IGridState {
1718
columns?: IColumnState[];
@@ -24,6 +25,7 @@ export interface IGridState {
2425
rowSelection?: any[];
2526
columnSelection?: string[];
2627
rowPinning?: any[];
28+
pinningConfig?: IPinningConfig;
2729
}
2830

2931
export interface IGridStateOptions {
@@ -37,6 +39,7 @@ export interface IGridStateOptions {
3739
rowSelection?: boolean;
3840
columnSelection?: boolean;
3941
rowPinning?: boolean;
42+
pinningConfig?: boolean;
4043
}
4144

4245
export interface IColumnState {
@@ -69,6 +72,7 @@ const GROUPBY = 'groupBy';
6972
const PAGING = 'paging';
7073
const ROW_SELECTION = 'rowSelection';
7174
const ROW_PINNING = 'rowPinning';
75+
const PINNING_CONFIG = 'pinningConfig';
7276
const CELL_SELECTION = 'cellSelection';
7377
const COLUMN_SELECTION = 'columnSelection';
7478

@@ -224,6 +228,10 @@ export class IgxGridStateDirective {
224228
this.restoreRowPinning(state as any[]);
225229
break;
226230
}
231+
case PINNING_CONFIG: {
232+
this.restorePinningConfig(state as IPinningConfig);
233+
break;
234+
}
227235
case CELL_SELECTION: {
228236
this.restoreCellSelection(state as GridSelectionRange[]);
229237
break;
@@ -291,6 +299,10 @@ export class IgxGridStateDirective {
291299
Object.assign(state, this.getRowPinning());
292300
break;
293301
}
302+
case PINNING_CONFIG: {
303+
Object.assign(state, this.getPinningConfig());
304+
break;
305+
}
294306
case CELL_SELECTION: {
295307
Object.assign(state, this.getCellSelection());
296308
break;
@@ -377,6 +389,10 @@ export class IgxGridStateDirective {
377389
return { rowPinning: pinned };
378390
}
379391

392+
private getPinningConfig(): IGridState {
393+
return { pinningConfig: this.grid.pinning };
394+
}
395+
380396
private getColumnSelection(): IGridState {
381397
const selection = this.grid.selectedColumns().map(c => c.field);
382398
return { columnSelection: selection };
@@ -465,6 +481,10 @@ export class IgxGridStateDirective {
465481
state.forEach(rowID => this.grid.pinRow(rowID));
466482
}
467483

484+
private restorePinningConfig(state: IPinningConfig) {
485+
this.grid.pinning = state;
486+
}
487+
468488
private restoreColumnSelection(state: string[]) {
469489
this.grid.selectColumns(state);
470490
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export class GridRowPinningSampleComponent implements OnInit {
2121
sorting: true,
2222
groupBy: true,
2323
columns: false,
24-
rowPinning: true
24+
rowPinning: true,
25+
pinningConfig: true
2526
};
2627

2728
@ViewChild('grid1', { static: true })

0 commit comments

Comments
 (0)