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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Refresh grid content after changing datasource 2018

Thread ID:

Created:

Updated:

Platform:

Replies:

141239 Nov 30,2018 02:49 PM UTC Dec 4,2018 12:51 PM UTC WinForms 3
loading
Tags: SfDataGrid
Adam
Asked On November 30, 2018 02:49 PM UTC

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

Deivaselvan Y [Syncfusion]
Replied On 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 


Adam
Replied On December 4, 2018 08:03 AM UTC

Working very well
Thank you :-)

Deivaselvan Y [Syncfusion]
Replied On December 4, 2018 12:51 PM UTC

You are welcome. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

;