Hello,
I currently have a WinGrid using a DataTable as the datasource. The DataTable contains records that I retreived from an SQL server via a Stored Procedure. When I refresh(rebind) the WinGrid after refreshing the DataTable any selections or expanded nodes, etc will be lost and the grid layout is reset.
What is the proper way to preserve the layout, selections, and expanded nodes after refreshing the data in the underlying DataTable. The data is view only in the WinGrid and is refreshed from the SQL Server every minute or so.
Any suggestions would be appreciated.
Matt
I am prob wrong about this because I haven't been in WinGrid in a while now but if memory serves the webgrid has a savelayout that might do what you want.
Yes, I am familiar with the save layout, however it doesn't seem to save the state of user selections, example:if the user has grouped on a column and they have row 5 expanded then when I rebind all of the rows are collapsed.
Hi,
Which event would be best to perform this action. I tried BindingContextChanged but it seems to only execute only the first time (the layout of the binding source doesn't change. Here's what I want to do:
- An action is performed to refresh the data
- Before refresh, I save the state of the group by rows to a list
- The binding source of the grid is set and the data is refreshed
- After the refresh, I restore the state of the group by rows that are a part of the list
I would like to keep all of these operations in a UltraWinGrid component that I created used in all screens.
Thanks
E
You could use the InitializeLayout event of the grid to restore the layout.
There's no event of that grid that will fire before the Data Source is changed, of course. So you will need to save the layout wherever you are changing the data source in your code.
I have a binding source object which the grid is bound to and I am setting its DataSource property which will automatically refresh the grid's data. In order for InitializeLayout to be called at each refresh, I would also have to set the grid's DataSource property to the binding source object, otherwise the InitializeLayout is only being called once.
Are you sure? I haven't tested this, but I would assume that setting the DataSource on the BindingSource sends a Reset notificaiton which would cause the grid to fire the InitializeLayout event.
I could be wrong. If I am, then once again, there's no event in the grid you can use. Perhaps you could trap some event of the BindingSource itself?
What you are trying to achieve can be done by creating a new datatable in memory and then merge that new datatable with the one binded to the grid. Look up datatable.merge. This will not reset the grid.
You should be able to call .Rows.Refresh(RefreshRow.ReloadData); method from the grid. I got this to work smoothly in one project, but having issues with it on another, not sure if it is the enterprise library or the control itself.
I am binding to LINQ entities, not to a datatable.