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.
Unfortunately, activation email could not send to your email. Please try again.

How can I resize child tables of GridGroupingControl ?

Thread ID:

Created:

Updated:

Platform:

Replies:

18070 Aug 23,2004 11:05 PM Aug 4,2010 02:52 AM Windows Forms 4
loading
Tags: GridControl
Michael Feinstein
Asked On August 23, 2004 11:05 PM

I have GridGroupingControl which points to a dataset with 2 related tables (so records of one table shown as children for another). How do I autosize those nested tables ? Calling gridGroupingControl1.TableModel.ColWidths.ResizeToFit() method only resizes Parent table. I am begining to think that having 2 tables and relationships is not a good idea, as many methods and events are not working properly (the most difficulat are this one and setting SaveCellFormattedText event). Is there a better solution to display 2 related tables then setting grid datasource to parent table ?

Administrator [Syncfusion]
Replied On August 24, 2004 06:49 AM

Hi Michael, the grouping control has a built-in automatic sizing mechanism that keeps track of the maximum width in characters of each column and sets the column width with a formula that multiplies the maximum number of characters for that column with the average font width. You can turn this mechanism off by setting AllowCalculateMaxColumnWidth = false. In order to manually resize the columns of a related table and all its child tables it helps to know how the connection between parent and child table is set. The parent table has records with NestedTable elements. NesteTable elements have a reference to a ChildTable which belongs to the related table. The related table is grouped by the RelationChildColumns into groups of ChildTable elements. When the parent table displays the contents of a child table it sets the related tables Table.FilteredChildTable to the table that should be displayed. Once FilteredChildTable has been specifed Model.RowCount and other methods will only operate on that specific child table. So, if you want to operate on the related table as a whole including all child tables, you can set FilteredChildTable = null. Example: In the HierarchyView example add the following lines of code to resize cells of all "Orders" child tables. this.gridGroupingControl1.GetTableDescriptor("Orders").AllowCalculateMaxColumnWidth = false; GridTableModel tm = this.gridGroupingControl1.GetTableModel("Orders"); tm.Table.FilteredChildTable = null; tm.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders); Stefan

Administrator [Syncfusion]
Replied On August 24, 2004 10:55 AM

Thank you, this information is invaluable and solved this and other problems for me! >Hi Michael, > >the grouping control has a built-in automatic sizing mechanism that keeps track of the maximum width in characters of each column and sets the column width with a formula that multiplies the maximum number of characters for that column with the average font width. > >You can turn this mechanism off by setting AllowCalculateMaxColumnWidth = false. > >In order to manually resize the columns of a related table and all its child tables it helps to know how the connection between parent and child table is set. > >The parent table has records with NestedTable elements. NesteTable elements have a reference to a ChildTable which belongs to the related table. > >The related table is grouped by the RelationChildColumns into groups of ChildTable elements. > >When the parent table displays the contents of a child table it sets the related tables Table.FilteredChildTable to the table that should be displayed. Once FilteredChildTable has been specifed Model.RowCount and other methods will only operate on that specific child table. > >So, if you want to operate on the related table as a whole including all child tables, you can set FilteredChildTable = null. > >Example: > >In the HierarchyView example add the following lines of code to resize cells of all "Orders" child tables. > > > >this.gridGroupingControl1.GetTableDescriptor("Orders").AllowCalculateMaxColumnWidth = false; >GridTableModel tm = this.gridGroupingControl1.GetTableModel("Orders"); >tm.Table.FilteredChildTable = null; >tm.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders); > > > >Stefan >

Bill Cowart
Replied On July 29, 2010 01:45 PM

Hi,


I tried this solution with a slight modification to recurse. if I uncomment the commented line in the method below, then when i run the sample and click a top level button to expand it on an item such as "Revenues", then nothing happens. If i leave the line commented, then the first nested tables column resizes well, but the child tables under that one do not.

ResizeColumns(grid.TableDescriptor);

public void ResizeColumns(GridTableDescriptor td)
{
//td.AllowCalculateMaxColumnWidth = false;
GridTableModel tm = grid.GetTableModel(td.Name);
tm.Table.FilteredChildTable = null;
tm.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.ResizeCoveredCells);
foreach (GridRelationDescriptor relation in td.Relations)
{
ResizeColumns(relation.ChildTableDescriptor);
}
}

snippit of data i am working with:
http://screensnapr.com/u/i/din6w4.png


Jisha Joy [Syncfusion]
Replied On August 4, 2010 02:52 AM

Hi Bill,

I have tested the issue in the attached sample. But it is working fine for me. Could you please reproduce the issue in the attached sample so that we could sort out the cause of the issue and provide you a solution based on it.

Regards,
Jisha



GGCResize_3376e476.zip

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.

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.

;