Hi all,
I have an object which contains a list of children (of the same type). In the main class i have a list of objects of this type and I have binded this to a grid grouping control. I think the control understand the relation between these objects and automatically displays the children of the parent object in a hierarchical manner.
My question is how do i auto-adjust the width of all columns to fill the available space? I have got this working for the root level but i dont really know how to do that for the levels beyond that.
thx
TE
test
April 11, 2008 09:44 AM UTC
Actually I have sorted this out but i realized that the border between the parent cells and the nested cells is not exactly aligned. I want the parent cells with the children cells to be exactly the same in terms of positioning and width.
Thanks
HA
haneefm
Syncfusion Team
April 12, 2008 12:19 AM UTC
Hi John,
If you want to align the ParentTable and ChildTable properly, you need to use the TrackWidhtofParentColumn property. You can use the below code snippet to resolve this issue.
private void SetTrackWidthOfParentColumn( GridTableDescriptor descriptor)
{
if (descriptor == null) return;
foreach (GridRelationDescriptor relationDescriptor in descriptor.Relations)
{
for (int n = 0; n < relationDescriptor.ChildTableDescriptor.VisibleColumns.Count ; n++)
{
relationDescriptor.ChildTableDescriptor.Columns[n].ResetTrackWidthOfParentColumn();
relationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = relationDescriptor.ParentTableDescriptor.Columns[n].Name;
}
SetTrackWidthOfParentColumn(relationDescriptor.ChildTableDescriptor);
}
}
For call the above method, please use this
SetTrackWidthOfParentColumn(this.gridGroupingControl1.TableDescriptor);
Best regards,
Haneef
TE
test
April 14, 2008 08:16 AM UTC
Works great but now the grid doesnt consume all the client area cause i had to remove the QueryColWidth handler to make the column alignment work. Is there any way to combine both? thx
HA
haneefm
Syncfusion Team
April 23, 2008 10:34 PM UTC
Hi JohnFish,
You can set the Colwidth of the last column by using the below code snippet to fill the client area. Below are the codes:
int width = this.gridGroupingControl1.TableModel.ColWidths.GetTotal(0, this.gridGroupingControl1.TableModel.ColCount - 2);
int clientwidth = this.gridGroupingControl1.ClientRectangle.Width;
this.gridGroupingControl1.TableDescriptor.Columns[ this.gridGroupingControl1.TableDescriptor.Columns.Count - 1].Widht = clientwidht - width;
Best regards,
Haneef