I am trying to use the SaveAsXml function to ONLY save the position and widths of columns. I do not want to save any other properties of the grid, e.g. DisplayLayout, GroupByBox, UltraGridOverride etc.
I want to save *just* UltraGridColumns, so that future code changes to other grid properties etc. are picked up.
I am using Grid.DisplayLayout.SaveAsXml(path_, PropertyCategories.SortedColumns); and it is saving all that extra stuff as well. I tried the other PropertyCategories and they don't seem to save what I want either.
Is there a setting I can pass in to save JUST the UltraGridColumns?
Try using PropertyCategories.Bands. If that doesn't work, then I there's probably no way to do it. I'm not sure why that is, though. Sounds like it might be a bug. Some categories have prerequisites for other categories. For example, you can't save the SortedColumn without also saving the Bands, because it would not make sense to have Sorted Column without columns (which are on the band). But I can't see why any category would automatically include the General category.
Thanks for the tip but it seems that Bands saves even more information than Sorted Column - certainly all the General stuff anyway.
Is this likey to be fixed in a future release? Currently we are using 2007 volume 2. Also on a related note, are newer versions able to read old layouts? i.e. if we created layouts in 2007.2 and upgrade to 2008.1 will they still be valid? I note in the xml there are a lot of 2007.2 xml schema declarations.
Thanks for your help.
goap said:Is this likey to be fixed in a future release?
Well, I recommend reporting this to Infragistics. Submit an incident to Infragistics Developer Support
I doubt that the current enum value can be "fixed", because this would potentially break existing applications. But they might be able to add a new enum in the future that are more specific. Or I could be wrong, maybe this can be fixed.
goap said:are newer versions able to read old layouts?
Yes, absolutely. You should be able to load a layout created with an older version of the grid into a newer version of the grid. If that doesn't work, it's a bug.
it seem that doesn't work properly with version 8.3 (which is maybe my fault).
I handle the stuff like this:
Public Sub getGridSettings() If IO.File.Exists(GlobalData.appPath & "\settings\" & GridName) Then Dim file As New System.IO.FileStream(GlobalData.appPath & "\settings\" & GridName, IO.FileMode.Open) show_grid.DisplayLayout.LoadFromXml(file, PropertyCategories.SortedColumns) file.Close() End If End Sub Public Sub setGridSettings() Try If Not IO.Directory.Exists(GlobalData.appPath & "\settings") Then IO.Directory.CreateDirectory(GlobalData.appPath & "\settings") End If Dim f As New System.IO.FileStream(GlobalData.appPath & "\settings\" & GridName, IO.FileMode.OpenOrCreate) show_grid.DisplayLayout.SaveAsXml(f, PropertyCategories.SortedColumns) f.Close() Catch ex As Exception End Try End Sub Private Sub AfterColPosChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterColPosChangedEventArgs) setGridSettings() End Sub
After setting the grids datasource i read the setting via get getGridSettings.
This is working until the user do some grouping. In this case the gridsettings save the also the grouping.But i would just save the column positions.
To deactivate the grouping the user has to drop the Group back to the Columns (as usual) and also change thewidth of some Column (which trigger the AfterColPosChangedEvent).One workaraund could be an event that will be fired if the user addor remove something from the "grouping-area", but i cant findthe proper event (grid events ...)Some idea?
If you only want to save the column positions, then why are you specifying PropertyCategories.SortedColumns? Sorting and grouping are tightly linked and you are explicitly telling the grid to save and load the sorting of the columns, to the grouping comes along with that.
Sorting in this case is the sorting of the rows, not the order of the columns. So it seems to me that you just need to specify Bands instead of SortedColumns.
aahhh, ok, it seems that i slightly misunderstand the word sortedColumns. Not the order of columns itself, it means the sorting itself,ok but anyway it als saves the width and visible position.
Yes, I can see how SortedColumns might be misunderstood. But it means the sorting and grouping, not the order of the columns. Some property categories have prerequisites. In this case, the width and position of the columns are also saved, because he grid cannot save the sorting and grouping without also saving the actual columns. So using SortedColums implicitly includes the option for Bands, as well.