Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to save a layout of LayoutControl together with its child controls

$
0
0

By default, if you save a layout of LayoutControl, settings of layout items are saved (Save and Restore Layout ). When you load the saved layout, layout items will be created with saved settings only if LayoutControl contains child controls, whose names exist in the saved layout. Otherwise, layout items will not be created. 


This example illustrates how to save settings of the child controls, too. For this, we have created two extension methods: SaveLayoutExToXml and RestoreLayoutExFromXml. These methods allow you to save and load child controls' settings. It makes sense to use these methods if it is necessary to re-create child controls from the saved layout with the saved settings. If a child control with the same name exists in LayoutControl, it will be removed and replaced by a new one retrieved from the saved layout. This approach is based on using a custom XmlXtraSerializer class. 

Question Comments

Added By: Ho-Jun Seo at: 9/4/2014 5:42:36 PM    

I am using version 12.1.12. It only has SaveLayoutToXml()  and RestoreLayoutFromXml(). So I cannot restore my layout with childs controls.
How can I use SaveLayoutExToXml()  and RestoreLayoutExFromXml() methods?

Added By: Andrey (DevExpress Support) at: 9/4/2014 11:03:29 PM    

Hello,
As I can see, you have created a separate How to use SaveLayoutExToXml() and RestoreLayoutExFromXml() methods?  thread. 

Since our support policy implies that every ticket is devoted to a separate issue, let's continue our discussion there.

Added By: Adam Ziegler at: 2/16/2018 9:47:53 AM    Boy, it sure would be a lot more helpful if this article also included the code for the two methods below. As it stands, it isn't helpful at all. Added By: Svetlana (DevExpress Support) at: 2/19/2018 6:03:58 AM    

Hi Adam,

This is not an article; it is a Code example that illustrates how to create two custom methods: SaveLayoutExToXml and RestoreLayoutExFromXml. Code of these methods is contained in the Serializer class of this example. To download this example, click the Example link on the right. You can also review this class' implementation by choosing Serializer.cs in the first combo box as shown in this screenshot

Added By: Francisco Matamoros at: 11/7/2018 4:43:45 AM    Hi, I am using this class to save the LayoutControlItems of a dynamic LayoutControlGroup.
When I generate each LayoutControlItem I use the Tag property to store an object from my database related to the LayoutControlItem.
When recovering with RestoreLayoutExFromXml I see that the Tag property despite being seen in the xml perfectly is not recovered.
Could I change something in the Serialized class so that it recovers correctly?
Thank you.

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>