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

Dynamic multiheader

Open ivanovla opened this issue 7 years ago • 8 comments

Hello. I do table with remote data and different config. I wants build table with multi header( Tab index). In order to achieve this, I recursively insert columns and it does not work. How can I still achieve this? Thanks in Advance. image

app-group-columns.html:

image

ivanovla avatar Jul 23 '19 11:07 ivanovla

@kdinev, @zdrawku. Is there any information?

ivanovla avatar Aug 05 '19 07:08 ivanovla

@ivanovla I don't see any reason this to be a problem, could you please share with me the exact version of our product that you are using?

zdrawku avatar Aug 05 '19 08:08 zdrawku

@ivanovla Я не вижу причин, чтобы это было проблемой, не могли бы вы поделиться со мной точной версией нашего продукта, который вы используете?

The problem is that if I wrap igx-column or igx-column-group in other component, I get an empty table. Columns are not initialized. And in another recursive insertion, I cannot achieve.

Now i insert inside igx-grid bad code with repeat:

image

What i expect: image

What i get if use component wrapper: image

ivanovla avatar Aug 06 '19 07:08 ivanovla

@zdrawku Is there any information?

ivanovla avatar Sep 06 '19 13:09 ivanovla

He @ivanovla, your approach is pretty good. Having config with structural purposes is cleaner and will reduce the template code of your application indeed. I've used your approach in order to try to replicate the issue and everything seems to be working file with manual configuration of the nested levels. As for the recursion with custom ng-content, this is currently no possible, as @rkaraivanov explained in that issue

the content children query can't be resolved for a tag/component which is not declared inside the parent content

By using ng-container grouping element and ngIf directive you can implement the desired configuration that is needed for dynamic creation of Multi-header and regular columns. As for the recursion, now I am defining every nested level manually, although if this is not what you men, please let me know.

Working sample with StackBlitz

Column configuration

public gridConfig =  {
      parentColumns: [
        {
          pHeader: "ID",
          field: "ID"
        },
        ...
        { 
          pHeader: "General Information",
          childColumns: [ 
              { header: "Company name", field: "CompanyName" }, 
              { header: "Contact Name", field: "ContactName" },
              { header: "Contact Title", field: "ContactTitle" } 
          ] 
        },
        {
          pHeader: "Address Information",
          childColumns: [
              {
                header: "Town Location",
                field: "Address"
              },
              {
                header: "Country Location",
                grandChildColumns: [
                  { header: "Country", field: "Country" }, 
                  { header: "Postal Code", field: "PostalCode" },
                  { header: "City", field: "City" },
                  { header: "Address", field: "Address" }
                ] 
              }, 
              ...
    };

igxGrid Columns configuration by using ng-container

...
<ng-container *ngFor="let childColumn of column.childColumns">
  <igx-column *ngIf="childColumn.field" [movable]="true" sortable="true" [header]="childColumn.header" [field]="childColumn.field"></igx-column>
  <igx-column-group *ngIf="childColumn.grandChildColumns" [movable]="true" [header]="childColumn.header" [filterable]="false">
    <ng-container *ngFor="let grandChildColumn of childColumn.grandChildColumns">
      <igx-column *ngIf="grandChildColumn.field" [movable]="true" sortable="true" [header]="grandChildColumn.header" [field]="grandChildColumn.field"></igx-column>
    </ng-container>
  </igx-column-group>
</ng-container>
...

zdrawku avatar Sep 13 '19 09:09 zdrawku

@zdrawku Yes, you sent me a similar example, as I wrote, only with more nesting. I do it because there is no choice. Too bad there is no solution with recursion, thanks for the support

ivanovla avatar Sep 23 '19 07:09 ivanovla

He @ivanovla, your approach is pretty good. Having config with structural purposes is cleaner and will reduce the template code of your application indeed. I've used your approach in order to try to replicate the issue and everything seems to be working file with manual configuration of the nested levels. As for the recursion with custom ng-content, this is currently no possible, as @rkaraivanov explained https://github.com/IgniteUI/igniteui-angular/issues/4966#issuecomment-498232941

@zdrawku there are any news after 5 years? Thanks a lot

Edo2610 avatar Jun 17 '24 09:06 Edo2610

Any news ?

AndriiDidkivsky avatar Apr 23 '25 15:04 AndriiDidkivsky