Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1170
UltraGridLayout not serializable
posted

Hi,

We have an ultragrid in which we bind different kinds of objects depending on an external property. We would like to have a save layout and update layout functionality through which we can save layouts for grid display for different objects in a single file. We have created a dictionary<typeOfObjectBindedToGrid, UltraGridLayout> and trying to xml-serialize it into a file.

It appears that the UltraGridLayout is not serializable and is returning error {"Infragistics.Win.UltraWinGrid.ColScrollRegion cannot be serialized because it does not have a parameterless constructor."}

Can you please let me know an elegant way to handle this keeping in view that the properties in the objects keep changing with the enhancements and the old layout file are loaded for the grids.

Thanks,

Puneet

Parents
  • 469350
    Offline posted

    Hi Puneet,

    I'm not sure why you are getting that error message. But the grid has built-in code to save and load the layout. So it's definitely possible to do so. My best guess is that something in the way in which you are doing the serialization is causing the error. But you didn't post that code here so that's only a guess.

    If you have a fixed number of potential layouts, then the easiest thing to do would be to save each layout to a stream. You could create a FileStream and then save the layouts to the stream in order. Of course, if you are binding the grid to each data source in an arbitrary order, that would be problematic. So what you could do is just create a bunch of UltraGridLayout variables: one for each possibly layout.

    Every time the user switches from one layout to another, you store the current layout in the variable for that layout using layout.CopyFrom. That way you store each layout in memory. When it comes time to write the layouts to a file, you create the file stream and then save each layout in a particular order. When you want to load them back in, you load each layout from the file stream into your layout variables in the same order. This has the added advantage of having the layout already in memory - so when the user switches to a new layout, you don't have to access the file every time, you just load it from the variable.

Reply Children