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

Refresh grid content after changing datasource 2018

I have still a problems with sfDataGrid after change DataSource.
I fond a topic from 2007 https://www.syncfusion.com/forums/62003/refresh-grid-content-after-changing-datasource but it don´t working any more ;-)
So here my question: how I can completly reset a DataGrid to "zero status"
I try it with:
dGrid.DataSource = null;
dGrid.Refresh();
so was ok... BUT if I using
dGrid.ShowBusyIndicator = true;
on the line
dGrid.Add(new GroupColumnDescription() { ColumnName = "DispayStatus" });
come error:
GroupColumnDescription already exist in DataGrid.GroupColumnDescriptions
I try also clear that (before Refresh) with:
dGrid.GroupColumnDescriptions.Clear();
but become error:
The object reference was not set to an object instance

Do you have some new update for this issue? Thanks

3 Replies

DY Deivaselvan Y Syncfusion Team December 3, 2018 11:14 AM UTC

Hi Adam, 

Thank you for contacting Syncfusion support.

 
Setting SfDataGrid.DataSource to null is enough to reset a DataGrid to zero state. But while using busy indicator we have used BackgroundWorker to perform asynchronous operations. In such case, the reported issue will occur, since it tries to add the GroupColumnDescription before clearing the GroupColumnDescriptions collection. This behavior is confirmed as a defect and it will be fixed in our 2018 Volume 4 SP1 release which is expected to be rolled out in the end of January 2019. 

However, you can resolve this issue by clearing the GroupColumnDescriptions collection before adding a GroupColumnDescription. It is advisable to clear all the collections related to the MappingName of the columns as given in the code example. Please refer the following code example and sample from the given location. 

Code example:  

private void OnRefreshButtonClick(object sender, System.EventArgs e) 
{ 
    this.sfDataGrid.DataSource = null; 
    this.sfDataGrid.DataSource = data.OrdersListDetails; 
    this.sfDataGrid.ClearGrouping(); 
    this.sfDataGrid.ClearSorting(); 
    this.sfDataGrid.ClearFilters(); 
    this.sfDataGrid.TableSummaryRows.Clear(); 
    this.sfDataGrid.GroupSummaryRows.Clear(); 
    this.sfDataGrid.GroupColumnDescriptions.Add( 
      new Syncfusion.WinForms.DataGrid.GroupColumnDescription() 
      { 
          ColumnName = "OrderID" 
      }); 
} 
 


Regards, 
Deivaselvan 



AD Adam December 4, 2018 08:03 AM UTC

Working very well
Thank you :-)


DY Deivaselvan Y Syncfusion Team December 4, 2018 12:51 PM UTC

You are welcome. 


Loader.
Up arrow icon