Hi,
I have ultragrid and its layout is being defined in InitializeLayout event. (Visible columns/Column Width/ColumnOrder etc.). Its datasource is set to Datatable. I have a refresh button which causes Datatable to reloaded and is bind to grid. The operations I can perform on grid at runtime: 1) Hide/Unhide columns using ColumnChooser. 2) Change Column width. 3) Change columns order. So after doing above operations and then clicking Refresh button, grid's source is refreshed and thus above changes to Grid UI are lost as grid's InitializeLayout is called. Can anyone help me in this regard ?
Probable solution I will be implementing: Maintaining Grid's layout in the form of xml in cache, and whenever there is change in Grid's property,(PropertyChange Event) will update that xml object. And thus if datasource is changed, grid's layout will be set from xml object in InitializeLayout event.
The problem with above solution is that PropertyChange event fires many times. So updating xml cache object will affect performance.
Please suggest any alternative solution.
Regards,
Karan
Hi Karan,
You don't need to track every property change on the grid.
What I would do is save the grid's layout to a stream before you begin modifying the datasource - so in the click event of the refresh button, the first thing you do is call grid.DisplayLayout.Save.
Then once the refresh is done, at the end of the event, you load the layout back into the grid with the Load method.
Hi Mike,
Thanks for the prompt reply. It seems fine to me, but I was thinking of saving layout to stream at some common place like some event (Before DataSource Change type event) as there can be many places where datasource is being set. Do we any event of similar functionality to this?
There's no event like this on the grid. But your code is setting the data source on the grid, so you can save the layout before you do so and restore it after.