jQuery UI Widgets Forums Angular jqxTree, ERROR TypeError: Cannot read property 'length' of null

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Ivo Zhulev 5 years, 3 months ago.

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

  • barboza
    Participant

    Hi all!

    I’m a newbie to this framework and to Angular as well.

    I created a tree

    <jqxTree #treeReference
             [width]="200" [height]="'100%'" [source]="projects | async">
    </jqxTree>
    

    with component code:

    
    import {AfterViewInit, Component, ViewChild, ViewEncapsulation} from "@angular/core";
    import {jqxTreeComponent} from "jqwidgets-scripts/jqwidgets-ts/angular_jqxtree";
    import "rxjs/add/observable/of";
    import * as  Rx from "@reactivex/rxjs";
    
    @Component({
      selector: "app-root",
      templateUrl: "./desktop.component.html",
      styleUrls: ["./desktop.component.css"],
      encapsulation: ViewEncapsulation.None
    })
    export class DesktopComponent implements AfterViewInit {
      height: number | string = 500;
      projects = this.projects = Rx.Observable
        .fromPromise(
          Promise.resolve([{id: 1, label: "TEST"}])).map((values: any[]) => {
          return values.map((p: any) => {
            return {id: p.id, label: p.name, parentid: p.parentId};
          });
        });
    
      @ViewChild("treeReference")
      tree: jqxTreeComponent;
    
    }
    

    I got an error:

    ERROR TypeError: Cannot read property ‘length’ of null
    at jqxTreeComponent.arraysEqual (webpack-internal:///../../../../jqwidgets-scripts/jqwidgets-ts/angular_jqxtree.ts:73)

    After spending some time in debug I came up to the conclusion, that there is a mistake in arraysEquals method.
    If I change the method to:

    arraysEqual(attrValue: any, hostValue: any): boolean {
        // check that previous/currentVlaue is undefined or null
        if ((attrValue && !hostValue) || (!attrValue && hostValue)) {
          return false;
        }
        if (attrValue.length != hostValue.length) {
          return false;
        }
        for (let i = 0; i < attrValue.length; i++) {
          if (attrValue[i] !== hostValue[i]) {
            return false;
          }
        }
        return true;
      }
    

    it begins to work.


    Ivo Zhulev
    Participant

    Hi barboza,

    Thanks for the report. This will be considered and if approved, added in the next release!

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.