Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9760

Re: Tree and json data binding

$
0
0

Hi Tomasz,

 

If you keep the names in your JSON file consistent you only need the one template. You can try the below JSON string and remove the logic for oSubNodeTemplate - you should get your desired result (all I've done is change your subitems to use the consistent name ("name") which is bound to your template)...

 

{          "mTypes": [ {                              "name" : "TYPE1",                              "description" : "TYPE1_desc",                              "details": [                                                  {                            "name": "ITEM1",                            "mDescription": "ITEM1_desc",                            "mDetails": {                                                                 "name": "1",                                            "mValue": "2"                                                       }                                       },                                                    {                                            "name": "ITEM2",                                               "mDescription": "ITEM2_desc",                            "mDetails": {                                                                 "mNumber": "3",                                                            "name": "4"                                                       }                                       }                                         ]                              },                              {                              "name" : "TYPE2",                              "description" : "TYPE2_desc",                              "details": [                                                  {                                                "name": "ITEM3",                                                 "mDescription": "ITEM3_desc",                                                "mDetails": {                                                                "mNumber": "5",                                           "name": "6"                                                       }                                       },                                                    {                                              "name": "ITEM4",                                                 "mDescription": "ITEM4_desc",                               "mDetails": {                                                            "mNumber": "7",                                                      "name": "8"                                                       }                                       }                                         ]                              }                              ]                   
};

 

So if you want the description to display in the tree insetad of ITEM1/ITEM2/etc you will need to change the naming around.

 

Hope this helps.

 

Regards,

Ian


Viewing all articles
Browse latest Browse all 9760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>