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. Image for the cookie policy date
close icon

Rewiring the GridFilterBar after DataTable update causes selection problems

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

4 Replies

AD Administrator Syncfusion Team September 21, 2004 07:48 PM UTC

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.


MA matt September 22, 2004 07:49 AM UTC

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.


AD Administrator Syncfusion Team September 22, 2004 11:09 AM UTC

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


MA matt September 22, 2004 12:25 PM UTC

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 > >

Loader.
Live Chat Icon For mobile
Up arrow icon