I have a Kendo React grid. data is coming from a fetch API. It works fine, but I have a drop down list that gets filled by another API.
Where do I fetch that data? Does anyone have a working example?
Thanks!!
3 Answers, 1 is accepted
0
Stefan
Telerik team
answered on 23 Sep 2020, 09:09 AM
Hello, Miriam,
This will depend on the application setup.
In general, we can recommend making the API request on the componentDidMount event (or hooks alternative) and setting the data in the state. Then using that data from the state in the DropDownList.
The request can be made inside each cell when it is opened, but this will make many unnecessary requests unless each DropDownList will have unique data based on an ID or other information.
Regards,
Stefan
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Thanks. not sure I understood. Do I fetch data in parent component (grid) or in child component (drop down list)?
0
Stefan
Telerik team
answered on 24 Sep 2020, 01:36 PM
Hello, Miriam,
Both places are possible, these are the differences:
1) Fetching the data in the Grid component and passing it to the child components - This is the recomended approach if the data in all DropDownList will be the same. This will make a single request and use the data in all DropDownList.
2) Fetching the data in the DropDownList component - This is recomended only when the DropDownList will have different data based on Grid rows. The downside it that this will produce many requests, but if they will be different then it is required.
The correct approach will depend on the application.
Regards,
Stefan
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.