We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Rewiring the GridFilterBar after DataTable update causes selection problems

Thread ID:

Created:

Updated:

Platform:

Replies:

19224 Sep 21,2004 09:42 AM Sep 22,2004 08:25 AM Windows Forms 4
loading
Tags: GridControl
matt
Asked On September 21, 2004 09:42 AM

Hi, I am having a problem with the GDBG and the GridFilterBar when I add/modify the DataTable of the grid. When I add/modify it causes the grid to scroll up to the top regardless of the current position and if I then scroll back down to where I was before, the selected row(s) and current cell are incorrect. When I add/modify the DataTable I first freeze painting of the grid, unwire the filter bar and then add/modify and then rewire the filter bar and unfreeze the grid. I believe it is to do wiring the filter bar again but don''t know the best way to: 1) Stop the scrolling back to the top of the grid. 2) Ensure that the selected rows and the current cell positions are correct. Any help would be greatly appreciated! Regards, Matt

Administrator [Syncfusion]
Replied On September 21, 2004 03:48 PM

If you are only adding new rows to the existing DataSource or modifying existing rows in the DataSource, I am not sure there is a need to wire and unwire the FilterBar. Here is a little sample. FilterBar_6788.zip If you filter on column 1 begins with r, and then click the buttons to either add a new row starting with r or not starting with r, things seems to behave as expected. If you change an existing row to no longer staify the filter (so it does not start with r), things still behave as expected. Now if you are actually changing the DataSource of the grid, then you would have to unwire and rewire the filterbar. But if this is the case, there would be no expectation that the data before the change would be the same as the data after teh change, and thus things like selections and current cells are not maintained as they may not make sense with the new data. If your situation is such that they will make sense, then you would have to cache CurrentCell.RowIndex/COlIndex before the change, and then reset it after the change using grid.CurrentCell.MoveTo to position the current cell to where it was before the change. If you want the selections to persist across this operation, you would have to cache grid.Selections.Ranges and reset them after the operation.

matt
Replied On September 22, 2004 03:49 AM

Hi Clay, Thank you very much for your quick response. I am only adding/modifying the one DataSource as you did in the example you attached. When I run your example it behaves as my code does but neither our versions update the filter with new values that have been added. In your example when I press the button to ''add X Row'' I need the ''xrow xcol'' value to be included in the drop down of the filter bar, but the only way I have found to do this is to unwire/rewire the filterbar to the grid. The same goes for the button that modifies row 2 of the grid. After I click the button the next time I view the filter options by clicking on the combobox I would expect to see the old value for row 2 removed and the new one in its place. Whatever changes I make to the datasource, none are reflected in the filterbar. Is there any way that this can be done without the need to unwire/rewire? Thanks again for your help, Matt >If you are only adding new rows to the existing DataSource or modifying existing rows in the DataSource, I am not sure there is a need to wire and unwire the FilterBar. Here is a little sample. > >FilterBar_6788.zip > >If you filter on column 1 begins with r, and then click the buttons to either add a new row starting with r or not starting with r, things seems to behave as expected. If you change an existing row to no longer staify the filter (so it does not start with r), things still behave as expected. > >Now if you are actually changing the DataSource of the grid, then you would have to unwire and rewire the filterbar. But if this is the case, there would be no expectation that the data before the change would be the same as the data after teh change, and thus things like selections and current cells are not maintained as they may not make sense with the new data. > >If your situation is such that they will make sense, then you would have to cache CurrentCell.RowIndex/COlIndex before the change, and then reset it after the change using grid.CurrentCell.MoveTo to position the current cell to where it was before the change. If you want the selections to persist across this operation, you would have to cache grid.Selections.Ranges and reset them after the operation.

Administrator [Syncfusion]
Replied On September 22, 2004 07:09 AM

If you want the filter droplists to be updated to reflect changes in grid, then you will have to do this yourself. Here is the sample back. If you add a new xrow, you will now see the xrow as an option in the filter drop lists. The sample does this by listening to the ColumnChanged event in the Datatable that is the DataSource of the grid. It then checks the new value to see if it is in the droplist. If it is not, the new value is added. FilterBar_4933.zip

matt
Replied On September 22, 2004 08:25 AM

Hi Clay, This is exactly what I need to do and will simplify my code a great deal. I imagine that this will solve the scrolling problem I has aswell. Thank you very much for prompt help! Regards, Matt >If you want the filter droplists to be updated to reflect changes in grid, then you will have to do this yourself. Here is the sample back. If you add a new xrow, you will now see the xrow as an option in the filter drop lists. > >The sample does this by listening to the ColumnChanged event in the Datatable that is the DataSource of the grid. It then checks the new value to see if it is in the droplist. If it is not, the new value is added. > > > >FilterBar_4933.zip > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;