Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Can I bind columns for tree grid to json data instead of fixed in the template
posted

Hi, I have just started a trial and looking at the Tree grid. Starting with the `tree-grid-virtualization-sample` example.

I wanted to be able support the case where I do not know what columns I have until runtime, so rather than hard coding them into the template, wante dto be able to format them in data, and do something like...

And then in code behind have something like...

this.columns  = [
      { dataField: "location", caption: "Location", allowResizing: true },
      {
        dataField: "room", caption: "Room", alignment: 'right', allowEditing: true, allowResizing: true,
        cellTemplate: 'cellTemplate', headerCellTemplate: 'headerTemplate'
      },
      { dataField: "cleanertype", caption: "cleaner type" },
      { dataField: "cleanerweight", caption: "cleaner weight" },
      { dataField: "totalweight", caption: "total weight" },
    ];

Ie defined the fieldnames, caption, and either cell templates or some sort of custom rendering.

Is this possible with these components?

Thanks i advance

  • 15
    Offline posted

    Actually I think I found the answer in hidden in sample tree-grid-conditional-cell-style-

    ie we use a *ngFor

    igx-column *ngFor="let c of columns"
                [field]="c.field"
                [header]="c.headerc.header : c.field"
                [cellStyles]="c.cellStyles">
    </igx-column>
  • 20
    Offline posted

    Hi,

    I am currently working on this and will update once I have more information.

    Best regards,
    Developer support
    Infragistics