4.1 GGC Rebind

Hi, I''m using GGC with TableDescriptors defined through a designer. The datasource of the GGC changes during runtime - it could be a valid DataSet or null. In second case the grid throws an exception: ************************************ Warning: Possible incorrect RelationDescriptor.ChildTableName for Relation RELATION_NAME. Engine.SourceListSet[SOME_RELATION] returned null. Did you forget to call Engine.SourceListSet.Add(new SourceListSetEntry(SOME_RELATION, list) or did you specify a wrong ChildTableName? Valid ChildTableName entries are: System.InvalidOperationException: Possible incorrect RelationDescriptor.ChildTableName for Relation DetailPackage. Engine.SourceListSet[Package] returned null. Did you forget to call Engine.SourceListSet.Add(new SourceListSetEntry(Package, list) or did you specify a wrong ChildTableName? Valid ChildTableName entries are: at Syncfusion.Grouping.Table.EnsureSourceList() at Syncfusion.Grouping.Table.EnsureInitialized(Object sender, Boolean notifyParent) at Syncfusion.Grouping.Element.EnsureInitialized(Object sender) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.UpdateColumnWidths(Boolean force) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.UpdateColumnWidths() at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.VisibleColumns_TotalWidthRequest(Object sender, CancelEventArgs e) at Syncfusion.Windows.Forms.Grid.Grouping.GridVisibleColumnDescriptorCollection.OnTotalWidthRequest(CancelEventArgs e) at Syncfusion.Windows.Forms.Grid.Grouping.GridVisibleColumnDescriptorCollection.get_TotalWidth() at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.GetHorizontalScrollWidth(Boolean isNested) at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.GetHorizontalScrollWidth(Boolean isNested) at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.GetHorizontalScrollWidth(Boolean isNested) at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.GetHorizontalScrollWidth() at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.OnQueryColWidth(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.RaiseQueryColWidth(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelColWidthsIndexer.OnQuerySize(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.GetSize(Int32 index) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.GridControlBase.GetColWidth(Int32 colIndex) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.RectangleToClientRowCol(Rectangle rect, Int32& topRow, Int32& leftCol, Int32& bottomRow, Int32& rightCol, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.GridPaint.DrawGrid(Graphics g, Boolean shouldClip, Rectangle rectClip) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe) catched at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe) in :line 0 What would be a correct approach to rebind data during the runtime? Thank you

4 Replies

AD Administrator Syncfusion Team February 22, 2006 05:48 PM UTC

Let me elaborate a little further: If I call this.gridGroupingControl1.ResetTableDescriptor(); this.gridGroupingControl1.TableDescriptor.Relations.Reset(); I obviously loose all descriptors, create at design time and do not want to recreate them manually everytime the datasource changes Thank you


AD Administrator Syncfusion Team February 22, 2006 06:36 PM UTC

The solution I found is the following: 1. In the costructor of the host form save GridRelationDescriptorCollection: col=(GridRelationDescriptorCollection)this.GGC.TableDescriptor.Relations.Clone(); 2. Set the DataSource in the following manner: this.GGC.SuspendLayout(); this.GGC.TableDescriptor.Relations.Reset(); if(ds!=null&&ds.Tables.Count>0&&ds.Tables[0].Rows.Count>0) { this.GGC.DataSource=ds.Tables[0]; this.GGC.TableDescriptor.Relations=col; } else { this.GGC.DataSource=null; } this.GGC.ResumeLayout(true); Is there more efficient ("right") way of doing it? Thank you


AD Administrator Syncfusion Team February 22, 2006 07:33 PM UTC

Hi Ivan, you could save the whole Engine with all its settings and nested relations using this code: GridEngine savedEngine = new GridEngine(); savedEngine.InitializeFrom(gridgroupingControl.Engine); Then you could reset the relations in your control if the datasource is null. If it is not null you can restore the engine settings with gridgroupingControl.Engine.InitializeFrom(savedEngine); The InitializeFrom logic can be used with any descriptors. The way you could also just save a TableDescriptor with nested relations and restore it back at a later time. Stefan


AD Administrator Syncfusion Team February 22, 2006 08:46 PM UTC

This works! Thank you for the detail explanation.

Loader.
Up arrow icon