Skip to content

Commit c85d03d

Browse files
MKirovaMKirova
authored andcommitted
feat(igxGrid): Expose sort templates inputs.
1 parent 2ab4d30 commit c85d03d

File tree

1 file changed

+96
-6
lines changed

1 file changed

+96
-6
lines changed

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

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,23 +1356,98 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
13561356
@ContentChild(IgxExcelStyleHeaderIconDirective, { read: TemplateRef })
13571357
public excelStyleHeaderIconTemplate: TemplateRef<any> = null;
13581358

1359+
13591360
/**
1360-
* The custom template, if any, that should be used when rendering a header sorting indicator when columns are sorted in asc order.
1361+
* @hidden
1362+
* @internal
13611363
*/
13621364
@ContentChild(IgxSortAscendingHeaderIconDirective, { read: TemplateRef })
1363-
public sortAscendingHeaderIconTemplate: TemplateRef<any> = null;
1365+
public sortAscendingHeaderIconDirectiveTemplate: TemplateRef<any> = null;
13641366

13651367
/**
1366-
* The custom template, if any, that should be used when rendering a header sorting indicator when columns are sorted in desc order.
1368+
* The custom template, if any, that should be used when rendering a header sorting indicator when columns are sorted in asc order.
13671369
*/
1370+
@Input()
1371+
public get sortAscendingHeaderIconTemplate(): TemplateRef<any> {
1372+
return this._sortAscendingHeaderIconTemplate;
1373+
}
1374+
1375+
/**
1376+
* Sets a custom template that should be used when rendering a header sorting indicator when columns are sorted in asc order.
1377+
* * ```html
1378+
* <ng-template #template igxSortAscendingHeaderIcon>
1379+
* <igx-icon>expand_less</igx-icon>
1380+
* </ng-template>
1381+
* ```
1382+
* ```typescript
1383+
* @ViewChild("'template'", {read: TemplateRef })
1384+
* public template: TemplateRef<any>;
1385+
* this.grid.sortAscendingHeaderIconTemplate = this.template;
1386+
* ```
1387+
*/
1388+
public set sortAscendingHeaderIconTemplate(template: TemplateRef<any>) {
1389+
this._sortAscendingHeaderIconTemplate = template;
1390+
}
1391+
1392+
13681393
@ContentChild(IgxSortDescendingHeaderIconDirective, { read: TemplateRef })
1369-
public sortDescendingHeaderIconTemplate: TemplateRef<any> = null;
1394+
public sortDescendingHeaderIconDirectiveTemplate: TemplateRef<any> = null;
1395+
1396+
/**
1397+
* The custom template, if any, that should be used when rendering a header sorting indicator when columns are sorted in desc order.
1398+
*/
1399+
public get sortDescendingHeaderIconTemplate() {
1400+
return this._sortDescendingHeaderIconTemplate;
1401+
}
13701402

13711403
/**
1372-
* The custom template, if any, that should be used when rendering a header sorting indicator when columns are not sorted.
1404+
* Sets a custom template that should be used when rendering a header sorting indicator when columns are sorted in desc order.
1405+
* * ```html
1406+
* <ng-template #template igxSortDescendingHeaderIcon>
1407+
* <igx-icon>expand_more</igx-icon>
1408+
* </ng-template>
1409+
* ```
1410+
* ```typescript
1411+
* @ViewChild("'template'", {read: TemplateRef })
1412+
* public template: TemplateRef<any>;
1413+
* this.grid.sortDescendingHeaderIconTemplate = this.template;
1414+
* ```
1415+
*/
1416+
public set sortDescendingHeaderIconTemplate(template: TemplateRef<any>) {
1417+
this._sortDescendingHeaderIconTemplate = template;
1418+
}
1419+
1420+
/**
1421+
* @hidden
1422+
* @internal
13731423
*/
13741424
@ContentChild(IgxSortHeaderIconDirective, { read: TemplateRef })
1375-
public sortHeaderIconTemplate: TemplateRef<any> = null;
1425+
public sortHeaderIconDirectiveTemplate: TemplateRef<any> = null;
1426+
1427+
/**
1428+
* Gets custom template, if any, that should be used when rendering a header sorting indicator when columns are not sorted.
1429+
*/
1430+
@Input()
1431+
public get sortHeaderIconTemplate(): TemplateRef<any> {
1432+
return this._sortHeaderIconTemplate;
1433+
}
1434+
1435+
/**
1436+
* Sets a custom template that should be used when rendering a header sorting indicator when columns are not sorted.
1437+
* * ```html
1438+
* <ng-template #template igxSortHeaderIcon>
1439+
* <igx-icon>unfold_more</igx-icon>
1440+
* </ng-template>
1441+
* ```
1442+
* ```typescript
1443+
* @ViewChild("'template'", {read: TemplateRef })
1444+
* public template: TemplateRef<any>;
1445+
* this.grid.sortHeaderIconTemplate = this.template;
1446+
* ```
1447+
*/
1448+
public set sortHeaderIconTemplate(template: TemplateRef<any>) {
1449+
this._sortHeaderIconTemplate = template;
1450+
}
13761451

13771452
/**
13781453
* @hidden
@@ -2930,6 +3005,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
29303005
private readonly DRAG_SCROLL_DELTA = 10;
29313006
private _dataCloneStrategy: IDataCloneStrategy = new DefaultDataCloneStrategy();
29323007
private _autoSize = false;
3008+
private _sortHeaderIconTemplate: TemplateRef<any> = null;
3009+
private _sortAscendingHeaderIconTemplate: TemplateRef<any> = null;
3010+
private _sortDescendingHeaderIconTemplate: TemplateRef<any> = null;
29333011

29343012
/**
29353013
* @hidden @internal
@@ -3503,6 +3581,18 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
35033581
* @hidden
35043582
*/
35053583
public ngAfterContentInit() {
3584+
if (this.sortHeaderIconDirectiveTemplate) {
3585+
this.sortHeaderIconTemplate = this.sortHeaderIconDirectiveTemplate;
3586+
}
3587+
3588+
if (this.sortAscendingHeaderIconDirectiveTemplate) {
3589+
this.sortAscendingHeaderIconTemplate = this.sortAscendingHeaderIconDirectiveTemplate;
3590+
}
3591+
3592+
if (this.sortDescendingHeaderIconDirectiveTemplate) {
3593+
this.sortDescendingHeaderIconTemplate = this.sortDescendingHeaderIconDirectiveTemplate;
3594+
}
3595+
35063596
this.setupColumns();
35073597
this.toolbar.changes.pipe(filter(() => !this._init), takeUntil(this.destroy$)).subscribe(() => this.notifyChanges(true));
35083598
this.setUpPaginator();

0 commit comments

Comments
 (0)