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
60
IgTreeGrid angular2 loadOnDemand sample
posted

Hi All!

I use igniteui igTreeGrid component (enableRemoteLoadOnDemand: true) with angular2.

import { Component } from '@angular/core';
import { RoutingComponent } from '../navigation/route.decorator';

declare var $: any;

const dataUrl = '/nodes.json';

@Component({          
    templateUrl: `<ig-tree-grid [(widgetId)]='id' [options]="tgridOptions"></ig-tree-grid>`
})
@RoutingComponent()
export class UsersTreeView {

    private id: string = 'tgrid';
    private tgridOptions: any;

    constructor() {
        
        this.tgridOptions = {                        
            autoCommit: true,            
            autoGenerateColumns: false,
            dataSource: [],
            dataSourceUrl: dataUrl,                        
            enableRemoteLoadOnDemand: true,
            features: [
                { name: 'Resizing' },
                //{ name: 'RowSelectors', rowSelectorNumberingMode: 'sequential' },
                //{ name: 'Selection' }
            ],
            initialExpandDepth: 0,
            primaryKey: "id",
            childDataKey: "objects",
            renderExpansionIndicatorColumn: true,
            height: "400px",
            width: "100%",
            columns: [
                { key: "id", headerText: "id" },
                { key: "name", headerText: "name" },
                { key: "description", headerText: "description" }                
            ]
        };
    }
}

And here's nodes.json structure

[
  {
    "id": 0,
    "name": "Project Plan",
    "description": "6/2/2014",
    "objects": []
  },
  {
    "id": 1,
    "name": "Project Plan",
    "description": "6/2/2014",
    "objects": [
      {
        "id": 3,
        "objects": [ { "id":  4} ],
        "name": "3"
      }
    ]
  }
]


1. First node ({
    "id": 0,
    "name": "Project Plan",
    "description": "6/2/2014",
    "objects": []
  })

is not expanding instead of havingobjects(this is childkey) field array.

2. If treegrid options doesn't have dataSource (I'm using RemoteLoadOnDemand mode) property component gets error -Cannot read property 'length' of undefined

What settings I have lost to include into igTreeGrid to resolve such behaviour?

Thanks.

Parents Reply Children