Bind grid to one of several collections returned by server

1 Answer 11 Views
Data Source
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 18 Apr 2024, 03:17 PM

How do I bind a listbox datasource to one specific collection returned by a new window.kendo.data.DataSource({ ?

The datasource returns json with two collections like below, and I want to bind to one of the collections

{
"collection1": [
{
"id": "1",
"name": "ABC"
},
{
"id": "2",
"name": "DEF"
}
],
"collection2": [
{
"id": "1",
"name": "HIJ"
},
{
"id": "2",
"name": "KLM"
}
]
}

 

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 23 Apr 2024, 09:55 AM

Hello Morten,

You need to declare a dataSource and in the schema specify the collection you want to bind:

          dataSource: {
            transport: {
              read: "https://run.mocky.io/v3/fa4c7c54-455c-4621-8adb-bdf9c2e27a27"
            },
            schema: {
              data: function(response) {
                return response.collection1; 
              }
            }
          },

Dojo demo: https://dojo.telerik.com/efOcUMUm

Regards,
Nikolay
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Data Source
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Nikolay
Telerik team
Share this question
or