Giter VIP home page Giter VIP logo

Comments (7)

winni4eva avatar winni4eva commented on August 20, 2024 2

Thanks, got it working with the books example. Maybe you could add the demo link https://github.com/leovo2708/ngx-treeview/tree/master/src/demo to the Readme. Great job.

from ngx-treeview.

soubhikchatterjee avatar soubhikchatterjee commented on August 20, 2024 1

For anyone else who is still struggling with displaying the items, the items should be an array of TreeviewItem.

Working code here:

// Your.component.ts
import { TreeviewItem } from "ngx-treeview";

export class YourComponent implements OnInit {

  public items = [
    new TreeviewItem({
      text: "Vegetable",
      value: 2,
      checked: false,
      children: []
    })
  ];
}

// Your.component.html
    <ngx-treeview
      [config]="config"
      [items]="items"
      (selectedChange)="onSelectedChange($event)"
    >
    </ngx-treeview>

This is all!

from ngx-treeview.

leovo2708 avatar leovo2708 commented on August 20, 2024

Yes, you are using wrong binding data, it must be a list of TreeviewItem object, not JSON object.

from ngx-treeview.

winni4eva avatar winni4eva commented on August 20, 2024

It will be nice if you can provide me with some example data which works, I just tried this but it still returns the same error message.

    this._treeViewItem = new TreeviewItem({
       text: 'Vegetable', value: 2, children: [
         { text: 'Salad', value: 21 },
         { text: 'Potato', value: 22 }]
    });
    this._treeViewItem.children.push(new TreeviewItem({ text: 'Mushroom', value: 23, checked: false}));
    this._treeViewItem.correctChecked();
    
    <ngx-treeview
       [config]="config"
       [items]="_treeViewItem"
       (selectedChange)="onSelectedChange($event)">
   </ngx-treeview>

from ngx-treeview.

leovo2708 avatar leovo2708 commented on August 20, 2024

It's your mistake, I gave some examples but maybe you did't read them. My demo is here:
https://leovo2708.github.io/ngx-treeview/
And code is here: https://github.com/leovo2708/ngx-treeview/tree/master/src/demo

from ngx-treeview.

MatheusPetrachin avatar MatheusPetrachin commented on August 20, 2024

If I receive JSON from a Rest API can I do something like this? if so how can i do it, i have the same error

export class BookService {

permissions: TreeviewItem[] = [];

constructor(
private permissionService: PermissionService
) { };

getBooks(): TreeviewItem[] {

this.permissionService.getPermissionTree(89).subscribe(p => {
  this.permissions = p;
  return [this.permissions]
});

return [];

}
}

from ngx-treeview.

leovo2708 avatar leovo2708 commented on August 20, 2024

what error? You should read my examples, I define value property of TreeviewItem is any, you can use it.

from ngx-treeview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.