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

GGC ResizeToFit after setting a datasource 4.402.0.51

Hi,
I'm having an issue while calling ResizeToFit method of the GGC (4.402.0.51):
this.oGrid.TableControl.Model.ColWidths.ResizeToFit(GridRangeInfo.Auto(-1, -1), GridResizeToFitOptions.IncludeHeaders);

If the Datasource changes from null to a populated table, the everything works fine, if the GGC is bound to a table for the second time the following exception is thrown:
catched at Syncfusion.Grouping.RuntimeElementsInTableCollection.get_Count() in :line 0
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Grouping.Table.EnsureSortFields()
at Syncfusion.Grouping.Table.OnCategorizingRecords(TableEventArgs e)
at Syncfusion.Grouping.Table.CategorizeElements()
at Syncfusion.Grouping.Table.OnEnsureInitialized(Object sender)
at Syncfusion.Grouping.Element.EnsureInitialized(Object sender, Boolean notifyParent)
at Syncfusion.Grouping.Table.BaseEnsureInitialized(Object sender, Boolean notifyParent)
at Syncfusion.Grouping.Table.EnsureInitialized(Object sender, Boolean notifyParent)
at Syncfusion.Grouping.Record.AdjustRecordRowCount()
at Syncfusion.Grouping.Record.GetVisibleCount()
at Syncfusion.Grouping.Record.GetCounter()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterEntry.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetCounterTotal()
at Syncfusion.Grouping.Internals.ElementTreeTable.get_VisibleCount()
at Syncfusion.Grouping.DetailsSection.GetVisibleCount()
at Syncfusion.Windows.Forms.Grid.Grouping.GridGroupExtend.OnInitializeVisibleCounters(Group owner, GridGroupOptionsStyleInfo go)
at Syncfusion.Windows.Forms.Grid.Grouping.GridChildTable.OnInitializeVisibleCounters()
at Syncfusion.Grouping.Group.InitVisibleCounters()
at Syncfusion.Grouping.Group.GetVisibleCount()
at Syncfusion.Grouping.Element.GetCounter()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterEntry.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetCounterTotal()
at Syncfusion.Grouping.Internals.ElementTreeTable.get_VisibleCount()
at Syncfusion.Grouping.Table.GetVisibleCount()
at Syncfusion.Grouping.Element.GetCounter()
at Syncfusion.Grouping.RuntimeElementsInTableCollection.get_Count()
A first chance exception of type 'System.NullReferenceException' occurred in Syncfusion.Grid.Grouping.Windows.dll

Please advise.
Thank you

2 Replies

AD Administrator Syncfusion Team January 24, 2007 07:56 PM UTC

A little remark:
The column descriptors have Filter set to true.

In general the filter row handling has become unacceptable since 4.1 - it's even impossible to enable filter for a column desriptor in the designer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


AD Administrator Syncfusion Team January 24, 2007 09:36 PM UTC

Hi Ivan,

Before re-bind the datasource, you need to reset the main table descriptor by calling ResetTableDescriptor method and then reset the nested relations by calling TableDescriptor.Relations.Reset method. And also you need to reset the current record. Please try the suggestion and let me know if this helps.

[C#]
// 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();
this.gridGroupingControl1.Table.CurrentRecord = null;

//your re-bind code here

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon