Hi,
We are binding a XML Dataset, having one data table, to the UltrawinGrid. While doing so we are using Grid.DisplayLayout.ResetBands(); command in order to arrange the columns in the default positions incase the user has moved them manually. But this ResetBands is making the app work very slow. I have no child bands.
Tried with DisplayLayout.Reset but the field chooser is not seen once the grid loads again.
Appreciate any help on bringing the columns to the default positions and also have the field chooser.
I'm not sure I understand your question. When are you calling ResetBands? And when is the grid slow?
ResetBands just resets the properties on the bands to their defaults. This should not take very long and it certainly should not have any lasting effects that would slow down the grid after it's done. Unless maybe there are some properties you have set that are improving performance in the first place, like CellDisplayStyle on the column, and it's getting reset.
HI ,
Sorry for confusion. I am using one XSD dataset containing one Datatable bound with the grid for getting the column details of the data which is going to be displayed. There are around 500 columns to be populated. By binding the XSD Dataset, i can get the column headers and FieldChooser of the grid even where the grid does not have any data.
Actual scenario goes like this.
I want the columns to be arranged in a particular order. but when the user moves the column positions manually. i am unable to bring it back in its particular position unless i refresh the layout. i tried manythings but only Grid.Displaylayout.ResetBands worked out. but it happens at the expense of performance. Is there anything else i can do for the resetting column positions without clearing the DisplayLayout so that i wont lose the binding of XDS Dataset.
For example:
I have 5 columns in order 1| 2 |3|4|5. Now users tries to move the fifth column to bring it to front so it becomes like this 5|1|2|3|4. Now on one event , i am trying to arrange the columns in original order 1| 2 |3|4|5 by using visibleHeader.index for each columns but i could not rearrange without resetting layout Grid.Displaylayout.ResetBands .
Thanks in advance.
Setting the VisiblePosition property on the column headers is tricky.
If you simply loop through the columns in a foreach loop, for example, it will usually not work as you might expect. The reason for this is that when you assign a VisiblePosition to a column, any columns to the right of that position have their positions changed. So the only way to do this reliably is to assign the column positions in order.
So you would determine which column goes in position 0 and set it's VisiblePosition to 0.
Then you would determine which column goes in position 1 and set it's VisiblePosition to 1.
Then you would determine which column goes in position 2 and set it's VisiblePosition to 2.
etc.
That's the only way to ensure that the columns whose positions you set do not get modified by some other column you set later on.
Another option is to simply use the grid.DisplayLayout.Save and Load methods.