This is a migrated thread and some comments may be shown as answers.

React kendo grid setting array item as column field

1 Answer 890 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kurkula
Top achievements
Rank 1
Kurkula asked on 20 Mar 2019, 02:02 AM

I have products.json file with all categories as object. It works fine if the data format is in the below link but it fails if categories in that json is an array. I am trying to create a react grid with one column from array of category items.

Example: https://stackblitz.com/edit/react-txwobq?file=app/products.json
It works fine with categories block as

<Column field="Category.CategoryName" title="CategoryName" />

in grid code with the below json object

"Category" : {"CategoryID" : 1,"CategoryName" : "Beverages","Description" : "Soft drinks, coffees, teas, beers, and ales"}

But I get the external api in array format for categories like

"Category" : [{"CategoryID" : 1,"CategoryName" : "Beverages","Description" : "Soft drinks, coffees, teas, beers, and ales"}]

I tried reading this value in react kendo grid like this but no luck. What was the mistake I am doing?

<Column field="Category[0].CategoryName" title="CategoryName" />     

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Mar 2019, 12:49 PM
Hello, Kurkula,

Thank you for the details.

In this case, I can suggest parsing the data before passing it to the Grid.

I made an example of this approach:

https://stackblitz.com/edit/react-txwobq-uqnnfx?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Kurkula
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or