How to use JSON return in DropDownTree

2 Answers 64 Views
DropDownTree Hierarchical Data Source
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Lee asked on 19 Aug 2024, 07:40 PM | edited on 19 Aug 2024, 07:48 PM

I have a JSON return from an endpoint that is hierarchical in a way but has different field names on each level for the ID and text. How would I make a kendo Drop Down Tree with this data without having to recreate the entire list? I will need to use the valueMapper, loadOnDemand, and get the value like this: .value(). It is like this (except with a lot more records): 


[
  {
    stateId: 1,
    stateName: "Florida",
    cities: [
      {
        cityId: 1,
        cityName: "Orlando",
        stores: [
          {
            storeId: 101,
            storeName: "I4"
          },
          {
            storeId: 202,
            storeName: "International Drive",
          },
          {
            storeId: 240,
            storeName: "UCF"
          }
        ]
      }
    ]
  }
]


2 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 22 Aug 2024, 08:26 AM

Hello, Lee,

The only possible approach I can think of is to try a template with complex logic where you can check if a specific field is present. With the built-in features, there's no way to bind the DropDownTree to such a structure.

Let me know if you have any questions.

Regards,
Martin
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

0
Setven
Top achievements
Rank 1
Iron
Iron
answered on 29 Aug 2024, 09:01 AM

To use JSON data with Kendo DropDownTree, you can leverage the dataTextField, dataValueField, and valueMapper properties. Here's a basic example:

Tags
DropDownTree Hierarchical Data Source
Asked by
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Answers by
Martin
Telerik team
Setven
Top achievements
Rank 1
Iron
Iron
Share this question
or