jQWidgets Forums

jQuery UI Widgets Forums Getting Started server side rendering not working with jqxTree

This topic contains 1 reply, has 2 voices, and was last updated by  Todor 5 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • 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, please help!
    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>


    Todor
    Participant

    Hello lazzie,

    Please review the following example whether it fits your needs.

    Let us know if you need further assistance.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.