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
120
InitializeLayout being fired when Datasource is changed.
posted

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   

Parents
  • 469350
    Suggested Answer
    Offline posted

    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.

Reply Children