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.