RadGridView - LoadLayout
1 Answer 17 Views
Alex
Top achievements
Rank 1
Alex asked on 07 Jun 2021, 10:12 AM

I've got an issue with the way loadlayout works with the RadGridView.  My plan is when the user closes the screen the layout will be saved to an xml file.  Saving the xml works great.  On subsequent loads of the program if a new column has been added to the RadGridView since the layout was last saved when the loadlayout method is called the new column is lost entirely.

Does anyone already have a solution for this?  My work around will be to examine the xml first before loading to try and amend it before loading but i'm not sure if i'm missing something obvious?

 

Thanks!

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Jun 2021, 07:28 AM
Hello, Alex,
 
The described scenario seems to be correct considering the save/load layout functionality that RadGridView offers. Its purpose is to restore the preserved layout in the XML.
Before calling the LoadLayout method, you can iterate the RadGridView.Columns collection and store the columns information into appropriate data structure. After the layout is successfully loaded you can iterate this data structure with the stored columns and add the missing ones. Thus, you will ensure that the columns stored in the XML file will be added to the grid together with the columns coming from the applied DataSource that were missing in the XML file. 

I would recommend you to have a look at the following forum thread which is quite useful on this topic: https://www.telerik.com/forums/load-save-layout-customization#3063949 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Alex
Top achievements
Rank 1
commented on 08 Jun 2021, 07:46 AM

Thanks for the reply.

What you have described is what i was starting to think i might need to do.

I did see this link yesterday too.

Thanks for the help! :D

Alex
Alex
Top achievements
Rank 1
commented on 08 Jun 2021, 08:22 AM

Just to update and record my solution in case anyone stumbles upon this post.

Before i call loadlayout i capture a list of objects which contains for each column in the grid the name, headertext and fieldname. This is enough for me once the loadlayout is called to iterate through to check for the existance of the field. If the column isn't there i call grid.columns.add(name,headertext,fieldname).

I will likely add code to check for the removal of a column but i can't see this being as big an issue.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 08 Jun 2021, 09:00 AM

Alex, your approach sounds promising and pretty close to the demonstrated approach in the referred forum thread. Feel free to use it in order to preserve these columns that you need. 
Asked by
Alex
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or