First of all this is 2nd time I'm posting my question today - the previous message is gone
After upgrading to 4.402.0.51 I can no longer rebind datasets to the GGC:
1. When a DataSet binded to the GGC for the first time - everything seem to work/look fine.
2. When I bind another dataset with a different number of rows - the GGC displays the same amount of rows, that was in the first dataset.
If before setting the DataSource to a new DataSet I do DataSource=null - eveything works fine.
What would be a proper way of rebinding dataset to GGC 4.402.0.51?
Thank you
AD
Administrator
Syncfusion Team
January 19, 2007 08:16 PM UTC
Hi Ivan,
The GridGroupingRebind browser sample demonstrates the switching of datasources at runtime and how to reset the GridGroupingControl to its original empty state. The sample assigns different datasources (retrieved from the NorthWind MS Access database using OleDb) with different number of levels at runtime.The sample also demonstrates how to show additional nested tables in the GroupDropArea. Here is the code to change the dataset of the GridGroupingControl.
private void BindData(DataSet ds)
{
this.gridGroupingControl1.SuspendLayout();
this.gridGroupingControl1.DataSource = ds != null ? ds.Tables[0] : null;
// This is by design and allows users to swap the datasource at runtime without having to worry that manual changes to the schema are lost
// In order to Reset the main table descriptor and also the nested relations use the following two lines
this.gridGroupingControl1.ResetTableDescriptor();
this.gridGroupingControl1.TableDescriptor.Relations.Reset();
// Show group area
this.gridGroupingControl1.ShowGroupDropArea = true;
// Additional table descriptors currently have to be added manually
//We plan to provide a TableDescriptor.ShowInGroupDropArea property later to make this easier
AddGroupDropAreas(this.gridGroupingControl1.Table);
// Make changes to schema. See above notes how to reset changes
SetReadOnly(this.gridGroupingControl1.Table);
this.gridGroupingControl1.ResumeLayout(true);
}
Here is a sample path.
[install drive]\Syncfusion\Essential Studio\4.4.0.49\Windows\Grid.Grouping.Windows\Samples\FeatureSamples\GridGroupingRebind
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
January 19, 2007 08:38 PM UTC
Thank you for the response.
What do I need to do to preserve
Column and Relation discriptors, which are defined in designed mode?
Thank you
AD
Administrator
Syncfusion Team
January 19, 2007 09:20 PM UTC
Hi Ivan,
Before changing the underlying datasource, you can get the GridVisibleColumnDescriptorCollection and RelationDescriptorCollection from the table descriptor.And then set the TableDescriptor.VisibleColumns and TableDeriptor.Relations after changing the datasource. Here is a code snippet to do this.
GridVisibleColumnDescriptorCollection columns = this.gridGroupingControl1.TableDescriptor.VisibleColumns;
GridVisibleColumnDescriptor[] arr = new GridVisibleColumnDescriptor[columns.Count] ;
columns.CopyTo(arr,0) ;
GridRelationDescriptorCollection relations = this.gridGroupingControl1.TableDescriptor.Relations;
GridRelationDescriptor[] rrr = new GridRelationDescriptor[relations.Count];
relations.CopyTo(rrr,0);
//Your Rebind code here....
columns.AddRange(arr) ;
relations.AddRange(rrr);
Best Regards,
Haneef