jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • lazzie
    Participant

    For me I have the same problem with jqxTree, its not waiting for the subscribe method to finish, hence its not populating my tree.
    Here is my ts file

    import { Component, OnInit, ViewChild } from ‘@angular/core’;
    import { jqxTreeComponent } from ‘jqwidgets-ng/jqxtree’;
    import { ApiService } from ‘app/services/api.service’;

    @Component({
    selector: ‘app-sidebar’,
    templateUrl: ‘./sidebar.component.html’
    })
    export class SidebarComponent {
    @ViewChild(‘myTree’, {static: false}) myTree: jqxTreeComponent;
    data: any[]= [];
    records: any;
    constructor(private apiService:ApiService){
    let source:any = {
    datatype: ‘json’,
    datafields: [
    { name: ‘id’ },
    { name: ‘parentid’ },
    { name: ‘text’ },
    { name: ‘value’ }
    ],
    init: this.fnInitializer(),
    id: ‘id’,
    localdata: this.data
    };
    // create data adapter & perform Data Binding.
    let dataAdapter = new jqx.dataAdapter(source, { autoBind: true });
    this.records = dataAdapter.getRecordsHierarchy(‘id’, ‘parentid’, ‘items’, [{ name: ‘text’, map: ‘label’ }]);
    }

    fnInitializer()
    {
    this.apiService.getTree2().subscribe((list)=> {
    this.data = list;
    });
    }
    }

    and here is my view file

    <jqxTree #myTree [width]=”230″ [height]=”550″ [source]=”records”
    style=”margin-left: 20px; margin-top:73px; float: left”></jqxTree>

Viewing 1 post (of 1 total)