igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Add [toolbarTemplate] parameter to IgxGrid and IgxTreeGrid

Open luiscla27 opened this issue 4 years ago • 2 comments

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.

luiscla27 avatar Nov 17 '21 15:11 luiscla27

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Mar 16 '22 00:03 github-actions[bot]

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Jun 04 '22 00:06 github-actions[bot]

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Sep 27 '22 00:09 github-actions[bot]

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Nov 29 '22 00:11 github-actions[bot]

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Jan 29 '23 00:01 github-actions[bot]

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Apr 01 '23 00:04 github-actions[bot]

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.

mtsvyatkova avatar Apr 26 '23 13:04 mtsvyatkova