Algeroth
Algeroth

Reputation: 785

TreeList from Model and Store in Ext Js 6

I have big model in my EXTJs 6 project and I fill him by json data, for example:

{
  "data": [
    {
      "id": 1,
      "name": "name1",
      "type": "STRING",
      "table": "table1"
    },
    {
      "id": 2,
      "name": "name2",
      "type": "STRING",
      "table": "table2"
    }
  ]
}

I spend much time for find solution to how build and set my treelist and viewmodel to bind data from store and show it on treelist in this way:

table1
   name1
   STRING
table2
   name2
   table2

Can anyone explain with examples how do this? In the documentation is not enough information about bind data from store to tree. Thanks.

Upvotes: 0

Views: 1225

Answers (1)

Alexander
Alexander

Reputation: 20224

You will have to change your data format. A tree panel takes a tree store, does not work with a normal store, and a tree store takes data differently from the normal store (more like a tree).

As per the docs of TreePanel, Summary, first line:

A TreePanel must be bound to a Ext.data.TreeStore.

I found an old fiddle of mine that shows how easily the binding is then accomplished: https://fiddle.sencha.com/#fiddle/145b

Upvotes: 1

Related Questions