Add [toolbarTemplate] parameter to IgxGrid and IgxTreeGrid
Is your feature request related to a problem? Please describe.
I have a toolbar that I want to reuse in a bunch of different IgxGrid implementations, currently, I have to duplicate that code every time
Describe the solution you'd like
I want to reuse the same <igx-grid-toolbar> code on different IgxGrid or IgxTreeGrid, so I don't have to duplicate code on all my implementations, seems to me that the most natural way would be to use Angular content or inline template. the following example would be ideal:
<ng-template #toolbarTemplate>
<igx-grid-toolbar *ngIf="showToolbar" #toolbar>
<igx-grid-toolbar-title> ... </igx-grid-toolbar-title>
... custom elements
<igx-grid-toolbar-actions *ngIf="showToolbar">
<igx-grid-toolbar-advanced-filtering *ngIf="allowAdvancedFiltering"> </igx-grid-toolbar-advanced-filtering>
<igx-grid-toolbar-hiding (opened)="onOpenToolbarConfigUi($event)"></igx-grid-toolbar-hiding>
<igx-grid-toolbar-pinning (opened)="onOpenToolbarConfigUi($event)"></igx-grid-toolbar-pinning>
<my-custom-button-1></my-custom-button-1>
<my-custom-button-2></my-custom-button-2>
... more custom elements
</igx-grid-toolbar-actions>
</igx-grid-toolbar>
</ng-template>
<igx-grid #grid1 [toolbarTemplate]="toolbarTemplate"> ... and more </igx-grid>
<igx-grid #grid2 [toolbarTemplate]="toolbarTemplate"> ... and a lot more </igx-grid>
Describe alternatives you've considered
The only alternative I currently have seems to duplicate my code, an alternative expected result for this FR could be to print the template directly and receive additional parameters using a directive:
<ng-template #toolbarTemplate>
<igx-grid-toolbar *ngIf="showToolbar" #toolbar>
<igx-grid-toolbar-title> ... </igx-grid-toolbar-title>
... custom elements
<igx-grid-toolbar-actions *ngIf="showToolbar">
<igx-grid-toolbar-advanced-filtering *ngIf="allowAdvancedFiltering"> </igx-grid-toolbar-advanced-filtering>
<igx-grid-toolbar-hiding (opened)="onOpenToolbarConfigUi($event)"></igx-grid-toolbar-hiding>
<igx-grid-toolbar-pinning (opened)="onOpenToolbarConfigUi($event)"></igx-grid-toolbar-pinning>
<my-custom-button-1></my-custom-button-1>
<my-custom-button-2></my-custom-button-2>
... more custom elements
</igx-grid-toolbar-actions>
</igx-grid-toolbar>
</ng-template>
<igx-grid #grid1 ...>
<ng-container igxToolbarGridTemplate [ngTemplateOutlet]="toolbarTemplate"></ng-container>
... and more
</igx-grid>
<igx-grid #grid2 ...>
<ng-container igxToolbarGridTemplate [ngTemplateOutlet]="toolbarTemplate"></ng-container>
... and a lot more
</igx-grid>
Additional context
Breaking changes or new features might need to be replicated in a lot of places, this FR might solve version upgrade issues. Also, this issue is related to this discussion where I explain a lot more my use case.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
The igx-grid-toolbar is initially designed to be used only inside a specific grid. Though, we have considered changing the implementation, it was decided that the current approach is intentional and preferred.
As you have mentioned in the alternatives section, using content projection will allow you to have the toolbar defined in a template and then have that content projected in all the grids.