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

GridDataBoundGrid Sorted Refresh Problem

I am having a problem with the databoundgrid. When I attempt to do a refresh (i.e. clear the underlying data in the datatable and then reload it) when one of the rows are sorted in the grid, the last row in the grid gets duplicated. Are there any fixes or work arounds to this? I am using 2.0.6.2

7 Replies

AD Administrator Syncfusion Team August 26, 2004 02:17 PM UTC

Here is some code that might be overkill, but would probably work. grid.BeginUpdate(); grid.DataSource = null; //clear you DataTable and reload it... grid.DataSource = myDataTable; grid.EndUpdate(); grid.Refresh();


AD Administrator Syncfusion Team August 26, 2004 02:23 PM UTC

Thanks, that works. One more thing, is there a way to disable the sort durring the refresh and then re-enable it after the refresh. It seems to take much longer to load up the data, if sorting is turned on.


AD Administrator Syncfusion Team August 26, 2004 02:31 PM UTC

This probably has nothing to do with the grid as the grid should be disconnected from the datasource at this point. You could try saving dataTable1.DefaultView.Sort to a string, then set dataTable1.DefaultView.Sort = "", and then clearing your datatable, followed by resetting the saved value to see if that sppeds things up.


AD Administrator Syncfusion Team August 26, 2004 03:04 PM UTC

OK, the refresh is working now. However, I have another problem. In the Grid, I am using a GridFilterBar. I realized that I had to re-add the filter bar everytime I do a refresh. However, it seems to first draw the entire grid w/o the filter bar, and then re-draws it w/ the filter bar. This causes the grid to look jumpy on refresh. Is there a way to get around this. Michael Sabin


AD Administrator Syncfusion Team August 26, 2004 04:46 PM UTC

Normally, you can turn off grid drawing by calling grid.BeginUpdate(). Then later you can turn it back on by calling grid.EndUpdate. You may have to also then call grid.Refresh to repaint things.


AD Administrator Syncfusion Team August 26, 2004 05:42 PM UTC

I was able to stop this behavior if I first unwire the grid before the refresh, and re-wire it after loading the data. However, I still see the behavior if I am sorting on one of the columns. Oddly enough, I am using the form in an MDI tab pane, and if I switch to another form, the behavior goes away until is modify the sort again. Here is a code snippet of my refresh method: Refresh () { // save selected items GridRangeInfoList rangeList = new GridRangeInfoList(); grid.Selections.GetSelectedRanges(out rangeList, false); grid.Selections.Clear(); grid.BeginUpdate(); gridFilter.UnwireGrid(); grid.DataSource = null; datatable.Clear(); LoadData(datatable); grid.DataSource = datatable; gridFilter.WireGrid(grid, gridStyle); grid.EndUpdate(); grid.Refresh(); // restore the selected items foreach (GridRangeInfo rangeInfo in rangeList) grid.Selections.Add(rangeInfo); }


AD Administrator Syncfusion Team August 26, 2004 06:28 PM UTC

You are correct. If you are clearing your datatable, then I think you will have to unwire and then rewire the grid.

Loader.
Live Chat Icon For mobile
Up arrow icon