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

How can I resize child tables of GridGroupingControl ?

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 ?

4 Replies

Administrator August 24, 2004 10:49 AM UTC

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 August 24, 2004 02:55 PM UTC

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 >

BC Bill Cowart July 29, 2010 05:45 PM UTC

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 August 4, 2010 06:52 AM UTC

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
Loader.
Live Chat Icon For mobile
Up arrow icon