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

Destroying and recreating grid with new columns is not adding column headers

1 Answer 359 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 22 Apr 2021, 04:09 PM

So I have a grid that needs to have dynamically created columns based on miscellaneous fields in our database. I initially tried destroying and reinitializing the grid with the new options including the new columns, and then I found a forum post on Tree Lists that also suggested doing that so I assume it's the best option for dynamic columns. And it is working for my data, the new column data shows up in the grid, however the column titles are not showing up.

Any clue as to why the headers are not updating?

My new columns are formatted like so:

var newMiscellaneousColumn = {
                                            field: "MiscellaneousHeaderFields[" + y + "].FieldValue",
                                            title: sub.MiscellaneousHeaderFields[y].FieldName,
                                            width: 150,
                                            encoded: true,
                                            hidden: false
                                        };  

Looking in the kendo grid in the developer console shows my columns are there and seem to be setup correctly.

 

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Neli
Telerik team
answered on 27 Apr 2021, 11:54 AM

Hello Daniel,

Could you please provide a little bit more details on the implementation for destroying and recreating the Grid? You could find an example of how a widget should be destroyed correctly in the link below:

https://docs.telerik.com/aspnet-core/getting-started/helper-basics/destroy#destroying-helpers-manually

After the Grid is recreated you could also try to call the refresh method.

Here you will find a Dojo example where a Grid is destroyed and recreated on a button click. I will appreciate it if you could modify the provided sample in order to replicate the behavior and send it back to us. This way we could take a closer look and advise you further.

Regards,
Neli
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/.

Daniel
Top achievements
Rank 1
commented on 27 Apr 2021, 01:41 PM | edited

Thanks, Neli. The example link you provided for destroying helpers manually helped. After calling destroy, I added the call to empty the grid element and my headers now show.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or