0

From my database i get multiple json object, the json object looks as follows.

[{"id":"90","email_address":[email protected]"},{"id":"92","email_address":[email protected]"}]

Now i want to make a treeview in Extjs that gives this data in so called nodes. But how do i read multiple object in a treestore? I tried to read one object in a store but that did not work. On the internet i found no solutions so far(only nested json objects(which is not the case here).

Wrapping it up: the problem is that my store won't read multiple objects.

The object are dynamicly loaded(so for instance the json can have 1000 objects)

2
  • You need to insert both of them into Root Node created by yourself Commented Nov 4, 2014 at 10:00
  • The result objects are dynamic. So for instance it can be 4 or even 100 rows. Commented Nov 4, 2014 at 10:30

1 Answer 1

1

You need to wrap your data in the middleware layer of your app (on the server-side) into hierarchical data presentation. Also you'll need to add "leaf" attribute to tree leaves. Check fiddle for example

"root": {
            "expanded": true,
            "children": [
             {
                "id": "90",
                "text": "[email protected]", 
                "leaf":true
             },
              {
                "id" : "92",
                "text":"[email protected]",
                "leaf": true
             }]
        }

http://jsfiddle.net/pura0xza/

Sign up to request clarification or add additional context in comments.

3 Comments

So the returning json must be 1 object? I don't think that is possible because the objects represent multiple rows/records from the database(postgres)
The tree, by concept, exists for working with hierarchical data. If you need to represent just plain data, with no parent-child relationship - you sould use list, not a tree
@РоманГуйван is correct. You have to define a 'root' node and place all the items under its children as an array. Set 'rootVisible' to false if you do not want to show the 'root' node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.