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

Dynamically add columns of image type to GridColumnProps column collection

3 Answers 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mukesh
Top achievements
Rank 1
Mukesh asked on 20 Jul 2019, 01:16 PM

I have column collection of type GridColumnProps, i want to dynamically add columns to these collection. I there any way to do that.

 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Jul 2019, 08:14 AM
Hello, Mukesh,

Is it possible to provide a code to see how this collection is created and how it looks as a structure?

This will allow us to provide more to the point suggestion for the current use case.

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
0
Mukesh
Top achievements
Rank 1
answered on 23 Jul 2019, 06:38 AM

I have following collection of columns

 

const columns: GridColumnProps[] = [
{ "field": "category", "title": "Category" },
{ "field": "name", "title": "Name" },
{ "field": "height", "title": "Height", "filter": "numeric" },
{ "field": "width", "title": "Width", "filter": "numeric" },
{ "field": "depth", "title": "Depth", "filter": "numeric" }
];

 

i want to add image columns dynamically based on props value.

 

Is that possible to achive that??

0
Stefan
Telerik team
answered on 23 Jul 2019, 10:37 AM
Hello, Mukesh,

Thank you for the code.

The column can be added to the collection by pushing a new item inside the array based on the prop.

This can by done before the component mounts or during a custom event, but the the column has to be inside the state, so the app re-renders once the new column is added:

https://stackblitz.com/edit/react-mgnydp-87bkla?file=app/main.jsx

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
Mukesh
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Mukesh
Top achievements
Rank 1
Share this question
or