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

Using HOC with GridColumn

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arek
Top achievements
Rank 1
Veteran
Arek asked on 12 Jan 2021, 04:10 PM

Hello,

 

I'm trying to wrap GridColumn using high order component. I'd like to make reusable columns within our solution that are enhanced towards our needs.

However, I'm not able to get KendoReact Grid to display data when I try this approach.

I've put example of what I'm trying to do here:

 

https://stackblitz.com/edit/kendoreact-grid-hooks-pvhvv7?file=app/main.jsx

 

Thanks in advance for help!

Best regards,

Arek

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Jan 2021, 08:01 AM

Hello, Arek,

This is expected as the GridColumn is a so-called "property collector component" that is used only to set the Grid columns declaratively. The component itself is not used during rendering. There is an internal logic that checks if the component is of type GridColumn, so we know from which component to take the props.

In such cases, we recommend having the columns inside an array of objects where each object is a column.

In this way, when rendering the column, the developer can do many different checks and calculations and based on them to set the column or its props. 

The following example will render a random combination of column each time when it is loaded, showing how to achieve the dynamic effect:

https://stackblitz.com/edit/react-vzqjyz?file=app/main.jsx

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/.

Tags
General Discussions
Asked by
Arek
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Share this question
or