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

Correct Way to Refresh a GGC after underlying data has changed

We are using GGC version 6.3.0.6 and we are looking for advice on the best way to refresh the grid when the underlying data has changed.

This is the method that we currently use but it does not seem to work all of the time:

public void UpdateRecordsWithBackendData(RecordsInTableCollection records)
{
foreach (Record record in records)
{
// Force end on the current record
record.EndEdit();

// Get the back end data
record.EnsureValues();

// Purge the cache
record.ResetValues();
}
}


1 Reply

SR SubhaSheela R Syncfusion Team July 10, 2008 11:54 AM UTC


Hi Kevin,

Thanks for your interest in Syncfusion products.

Rebindng Datatable
you have to reset the DataSource before rebinding it. The best way to do this would be calling the grid.BeginUpdate() and grid.Binder.SuspendBinding() before you modify the underlying DataSource and call grid.Binder.ResumeBinding() and grid.EndUpdate() after that.

The SuspendBinding and ResumeBinding are two methods that allow the temporary suspension and resumption of data binding. You would typically suspend data binding if you want to make several changes to the data source without immediately updating the grid after each change.

For example, if you want to clear out all records in your data set and refill it with its original data, you can improve performance of this operation substantially if the grid does not need to immediately reflect every row change in the grid while the data set is filled.

BeginUpdate method suspends the painting of associated grid controls until the EndUpdate method is called.

Also, call grid.Binder.ResetHierarchyLevels() if you have changed the underlying data source and you had several relations added. Below is the code snippet:


this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.DataSource = null;
this.gridDataBoundGrid1.DataMember = null;
this.gridDataBoundGrid1.Binder.ResetHierarchyLevels();
this.gridDataBoundGrid1.Binder.InternalColumns.Clear();
this.gridDataBoundGrid1.DataSource = ds;
this.gridDataBoundGrid1.DataMember = "ParentTable";
this.gridDataBoundGrid1.EndUpdate();


Changing the underlying data only

Calling the grid.Engine.ResetTable() in the button event handler will help you to make the proper values appear.


this.gridGroupingControl1.Engine.ResetTable();


Please let me know if it helps.

Regards,
Subhasheela R





Loader.
Live Chat Icon For mobile
Up arrow icon