valor-software / ng2-tree

Angular tree component
http://valor-software.com/ng2-tree/index.html
MIT License
348 stars 190 forks source link

Change the structure of the TreeModel #263

Open ghost opened 6 years ago

ghost commented 6 years ago

So, im getting data from the database and it's something like this:

{ "nome": "ESTABELECIMENTO A", "children": [ { "nome": "Departamento A", "children": [ { "nome": "Serviço A1", "children": [] }, { "nome": "Serviço A2", "children": [] } ] }, { "nome": "Departamento B", "children": [ { "nome": "Serviço B1", "children": [] } ] } ] }

The structure of the tree has a filed named "VALUE" instead of "NOME". I've changed the structure of the tree, inside the node_modules folder, to this:

_export interface TreeModel { nome: string; id?: number; children?: TreeModel[]; loadChildren?: ChildrenLoadingFunction; settings?: TreeModelSettings; emitLoadNextLevel?: boolean; _status?: TreeStatus; _foldingType?: FoldingType;

}_

But still, im getting this : tree_not_working

What else do I need to change? Thank you!

horsacode commented 6 years ago

Try to change de field "nome" to "value". Remeber the struct of ng2-tree.

interface TreeModel { value: string | RenamableNode; id: string | number; children?: Array<TreeModel>; loadChildren?: ChildrenLoadingFunction; settings?: TreeModelSettings; }

You should use another method or controller to change field