ForeignKeyReference
I use ForeignKeyReference in GGC.
**********************************************************
gridGroupingControl1.DataSource = null;
gridGroupingControl1.DataMember = "";
gridGroupingControl1.TableDescriptor.Relations.Clear();
GridTableDescriptor mainTd = this.gridGroupingControl1.TableDescriptor;
string SourceListName = childTable.TableName;
this.gridGroupingControl1.Engine.SourceListSet.Add(SourceListName, childTable.DefaultView);
GridRelationDescriptor subTableRd = new GridRelationDescriptor();
subTableRd.Name = mainTable.Columns[2].ColumnName;
subTableRd.RelationKind = RelationKind.ForeignKeyReference;
subTableRd.ChildTableName = SourceListName;
subTableRd.RelationKeys.Add(mainTable.Columns[2].ColumnName, childTable.Columns[0].ColumnName);
mainTd.Relations.Add(subTableRd);
gridGroupingControl1.DataSource = mainTable;
***********************************************************
And I have a problem with a child table.
1) How to change its width?
2) When in the child table is 6 columns, the text in 6-th column is not fully visible. How to change the width of the 6-th column.
**********************************************************
gridGroupingControl1.DataSource = null;
gridGroupingControl1.DataMember = "";
gridGroupingControl1.TableDescriptor.Relations.Clear();
GridTableDescriptor mainTd = this.gridGroupingControl1.TableDescriptor;
string SourceListName = childTable.TableName;
this.gridGroupingControl1.Engine.SourceListSet.Add(SourceListName, childTable.DefaultView);
GridRelationDescriptor subTableRd = new GridRelationDescriptor();
subTableRd.Name = mainTable.Columns[2].ColumnName;
subTableRd.RelationKind = RelationKind.ForeignKeyReference;
subTableRd.ChildTableName = SourceListName;
subTableRd.RelationKeys.Add(mainTable.Columns[2].ColumnName, childTable.Columns[0].ColumnName);
mainTd.Relations.Add(subTableRd);
gridGroupingControl1.DataSource = mainTable;
***********************************************************
And I have a problem with a child table.
1) How to change its width?
2) When in the child table is 6 columns, the text in 6-th column is not fully visible. How to change the width of the 6-th column.
SIGN IN To post a reply.
8 Replies
RK
Ranjeet Kumar
Syncfusion Team
December 21, 2009 02:53 PM UTC
Hi Arsenii,
Thanks for your interest in Syncfusion Products.
You may set the width of the child table column as well as Parent table column as shown below with the help of code snippets:
To set the width of the Parent table column, click on the button with text "Parent Column Width" and to set the width of the Child table column, click on
the button with text "Child Column Width" :
//Event : button1_click
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
//Event : button2_Click
this.gridGroupingControl1.TableDescriptor.Columns[0].Width = 100;
Please find the sample from the following link in which this code has been implemented.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS_ChildColumn_Width-1548945230.zip
Please, do let me know if you have any query.
Regards,
Ranjeet.
Thanks for your interest in Syncfusion Products.
You may set the width of the child table column as well as Parent table column as shown below with the help of code snippets:
To set the width of the Parent table column, click on the button with text "Parent Column Width" and to set the width of the Child table column, click on
the button with text "Child Column Width" :
//Event : button1_click
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
//Event : button2_Click
this.gridGroupingControl1.TableDescriptor.Columns[0].Width = 100;
Please find the sample from the following link in which this code has been implemented.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS_ChildColumn_Width-1548945230.zip
Please, do let me know if you have any query.
Regards,
Ranjeet.
AK
Arseny Khutoriansky
December 22, 2009 06:57 AM UTC
Thank you for this solution.
How can I do it automatically?
If the text is longer than the width of the column of childTable, then the width changing automatically.
How can I do it automatically?
If the text is longer than the width of the column of childTable, then the width changing automatically.
AK
Arseny Khutoriansky
December 23, 2009 07:50 AM UTC
And how to change width of drop-down windows of childTable?
RK
Ranjeet Kumar
Syncfusion Team
December 24, 2009 05:45 AM UTC
Hi Arsenii,
Thanks for your interest in Syncfusion Products.
Post :1 .
Q.
How can I do it automatically?
If the text is longer than the width of the column of childTable, then the width changing automatically.
Sol.
To automatically change the width size of the child table as well as parent table , in this sample I have handled TableControlCurrentCellControlLostFocus event as shown below :
// Event :(Parent Table)
this.gridGroupingControl1.TableControlCurrentCellControlLostFocus += new GridTableControlControlEventHandler(gridGroupingControl1_TableControlCurrentCellControlLostFocus);
// Handler :
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(e.TableControl.CurrentCell.ColIndex));
// Event :(Child Table)
this.gridGroupingControl1.GetTableControl("table2").CurrentCellControlLostFocus += new ControlEventHandler(Form1_CurrentCellControlLostFocus);
// Handler :
GridTableControl tb = this.gridGroupingControl1.GetTableControl("table2"); this.gridGroupingControl1.GetTableModel("table2").ColWidths.ResizeToFit(GridRangeInfo.Col(tb.CurrentCell.ColIndex));
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GridGroupControl(AutoColWidthResizeOnLostFocus)708725756.zip
Post :2 .
Q.
And how to change width of drop-down windows of childTable?
Sol.
Since, this drop-down window of child table is acting as a cell , so we may handle the size of a cell with respect to the column header and by resizing the column width as shown below:
Please click on the button with text "Child window width" to resize the child table window size for which I have handled button1_click event.
// Event : button1_Click
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 80;
Similarly, you may also resize the parent window for which I have handled button2_click event,
//Event : button2_Click
this.gridGroupingControl1.TableDescriptor.Columns[2].Width = 60;
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC-ChildTableWindowWidth37524178.zip
Please do let me know if you have any query.
Regards,
Ranjeet .
Thanks for your interest in Syncfusion Products.
Post :1 .
Q.
How can I do it automatically?
If the text is longer than the width of the column of childTable, then the width changing automatically.
Sol.
To automatically change the width size of the child table as well as parent table , in this sample I have handled TableControlCurrentCellControlLostFocus event as shown below :
// Event :(Parent Table)
this.gridGroupingControl1.TableControlCurrentCellControlLostFocus += new GridTableControlControlEventHandler(gridGroupingControl1_TableControlCurrentCellControlLostFocus);
// Handler :
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(e.TableControl.CurrentCell.ColIndex));
// Event :(Child Table)
this.gridGroupingControl1.GetTableControl("table2").CurrentCellControlLostFocus += new ControlEventHandler(Form1_CurrentCellControlLostFocus);
// Handler :
GridTableControl tb = this.gridGroupingControl1.GetTableControl("table2"); this.gridGroupingControl1.GetTableModel("table2").ColWidths.ResizeToFit(GridRangeInfo.Col(tb.CurrentCell.ColIndex));
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GridGroupControl(AutoColWidthResizeOnLostFocus)708725756.zip
Post :2 .
Q.
And how to change width of drop-down windows of childTable?
Sol.
Since, this drop-down window of child table is acting as a cell , so we may handle the size of a cell with respect to the column header and by resizing the column width as shown below:
Please click on the button with text "Child window width" to resize the child table window size for which I have handled button1_click event.
// Event : button1_Click
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 80;
Similarly, you may also resize the parent window for which I have handled button2_click event,
//Event : button2_Click
this.gridGroupingControl1.TableDescriptor.Columns[2].Width = 60;
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC-ChildTableWindowWidth37524178.zip
Please do let me know if you have any query.
Regards,
Ranjeet .
AK
Arseny Khutoriansky
December 24, 2009 08:25 AM UTC
Hi, Ranjeet
Thank you for your response.
>
>//Event : button1_click
>
>this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
>
>
>Please find the sample from the following link in which this code has been implemented.
>
>
>http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS_ChildColumn_Width-1548945230.zip
>
I'm using this example for the child table in which the 6 columns.
This works for all columns except the last column.
>
>Q.
>How can I do it automatically?
>If the text is longer than the width of the column of childTable, then the width changing automatically.
>
>Sol.
>To automatically change the width size of the child table as well as parent table ,
> in this sample I have handled TableControlCurrentCellControlLostFocus event as shown below :
>
Your solution is right for the nested tables, but I asked about the tables as in the previos example.
If you look in the code which is given in my first post, you can see, there is "mainTable" and "childTable" related by ForeignKeyReference. In the "childTable" has 6 columns. For unknown reasons to me, 5 of them are displayed correctly, but 6-th did not fully show the text that are in it. (column width less than the length of the text). I need to fix it.
Following code for some reason, changing the width of any columns except the sixth(last), which is the problem
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
Regards,
Arsenii
Thank you for your response.
>
>//Event : button1_click
>
>this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
>
>
>Please find the sample from the following link in which this code has been implemented.
>
>
>http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS_ChildColumn_Width-1548945230.zip
>
I'm using this example for the child table in which the 6 columns.
This works for all columns except the last column.
>
>Q.
>How can I do it automatically?
>If the text is longer than the width of the column of childTable, then the width changing automatically.
>
>Sol.
>To automatically change the width size of the child table as well as parent table ,
> in this sample I have handled TableControlCurrentCellControlLostFocus event as shown below :
>
Your solution is right for the nested tables, but I asked about the tables as in the previos example.
If you look in the code which is given in my first post, you can see, there is "mainTable" and "childTable" related by ForeignKeyReference. In the "childTable" has 6 columns. For unknown reasons to me, 5 of them are displayed correctly, but 6-th did not fully show the text that are in it. (column width less than the length of the text). I need to fix it.
Following code for some reason, changing the width of any columns except the sixth(last), which is the problem
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["Name"].Width = 500;
Regards,
Arsenii
RK
Ranjeet Kumar
Syncfusion Team
December 24, 2009 11:05 AM UTC
Hi Arsenii,
Thanks for your interest in Syncfusion Products.
This sample consists of two tables and the child table contains 6 columns.
Please click on the button with text " Child Column Width" to resize the child table window size for which I have handled button1_click event.
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC(DropdownWindowColumnResize)620851072.zip
Please do let me know if you have any query.
Regards,
Ranjeet .
Thanks for your interest in Syncfusion Products.
This sample consists of two tables and the child table contains 6 columns.
Please click on the button with text " Child Column Width" to resize the child table window size for which I have handled button1_click event.
// Event : button1_Click
this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns[5].Width = 200;
Sample Link :
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC(DropdownWindowColumnResize)620851072.zip
Please do let me know if you have any query.
Regards,
Ranjeet .
AK
Arseny Khutoriansky
December 24, 2009 01:54 PM UTC
Ok))
Try to insert into childTable row with more long texts
usStates.Rows.Add(new object[] { "AL", "Alabama", "adad dawdad adawdad", "adad dawdad adawdad", "adad dawdad adawdad", "adad dawdad adawdad" });
Try to insert into childTable row with more long texts
usStates.Rows.Add(new object[] { "AL", "Alabama", "adad dawdad adawdad", "adad dawdad adawdad", "adad dawdad adawdad", "adad dawdad adawdad" });
LS
Lingaraj S
Syncfusion Team
December 25, 2009 05:57 AM UTC
Hi Aresenii,
Thank you for the update.
Please try using FillLastColumn property in GridTableDropDownListCellRenderer.ListControlPart to achieve auto resize behavior in foreign key column child table as shown below:
Refer the sample from below link:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Sample-706932420.zip
Please let me know if you have any queries.
Regards,
Lingaraj S.
Thank you for the update.
Please try using FillLastColumn property in GridTableDropDownListCellRenderer.ListControlPart to achieve auto resize behavior in foreign key column child table as shown below:
this.gridGroupingControl1.TableControlCurrentCellShowingDropDown += new GridTableControlCurrentCellShowingDropDownEventHandler(gridGroupingControl1_TableControlCurrentCellShowingDropDown);
void gridGroupingControl1_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
{
if (e.TableControl.CurrentCell.Renderer.StyleInfo.CellType.Equals("ForeignKeyCell"))
{
GridTableDropDownListCellRenderer ren = e.TableControl.CurrentCell.Renderer as GridTableDropDownListCellRenderer;
ren.ListControlPart.FillLastColumn = false;
}
}
Refer the sample from below link:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Sample-706932420.zip
Please let me know if you have any queries.
Regards,
Lingaraj S.
SIGN IN To post a reply.
- 8 Replies
- 3 Participants
-
AK Arseny Khutoriansky
- Dec 20, 2009 09:43 AM UTC
- Dec 25, 2009 05:57 AM UTC