i have two tables and two views attached to those tables
i have made a relation b/w tables
now if i set parent table''s view to grid
its fine
but when i set the child table''s view as datasource, the plus sign doesnt go .. it stays
how do i remove it?
AD
Administrator
Syncfusion Team
June 23, 2004 09:10 AM UTC
When you set the child view to be the grid''s datasource, try calling
this.gridDataBoundGrid1.Binder.ResetHierarchyLevels();
to see if that makes a difference.
M.
M.F.K.
June 23, 2004 09:45 AM UTC
I already tried that
besides that I need further help
I have 7 cols in parent table and 6 in child
i have set 7 grid bound cols in the grid
when parent view is there, its ok
but on child i want that extra col to be invisible and show up again on parent view
>When you set the child view to be the grid''s datasource, try calling
>
>this.gridDataBoundGrid1.Binder.ResetHierarchyLevels();
>
>to see if that makes a difference.
AD
Administrator
Syncfusion Team
June 23, 2004 12:03 PM UTC
Exactly what are you trying to do?
Are you trying to display parent-child relation in the grid like the grid\samples\DataBound\Hierarchy\ExpandGrid sample? If so, you do not set the grid''s DataSource to be the Child.
Or, are you trying to dynamically show the parent table in a grid, and then show a filtered view on the child table in the same grid? This would not be an expand-grid type set up. You would not use grid.Binder.AddRelations in this case. This would be more of a master-details set up.
If you will explain what you are trying to accomplish (or provide a sample),maybe we can suggest something.
M.
M.F.K.
June 24, 2004 07:16 AM UTC
Yes u got it ... I am trying this "Master-Details" as u said. Could u tell me more abt it? and how to accomplish it?
>Exactly what are you trying to do?
>
>Are you trying to display parent-child relation in the grid like the grid\samples\DataBound\Hierarchy\ExpandGrid sample? If so, you do not set the grid''s DataSource to be the Child.
>
>Or, are you trying to dynamically show the parent table in a grid, and then show a filtered view on the child table in the same grid? This would not be an expand-grid type set up. You would not use grid.Binder.AddRelations in this case. This would be more of a master-details set up.
>
>If you will explain what you are trying to accomplish (or provide a sample),maybe we can suggest something.
AD
Administrator
Syncfusion Team
June 24, 2004 07:41 AM UTC
There is a section in the grid''s User''s Guide(Grid OverView - GridDataBoundGrid Use cases) describing how to set up two Mater-Detail grids.
Here is a minimal sample.
There is another techniquer discussed in this forum thread that may be of use in particular cases. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9622
M.
M.F.K.
June 24, 2004 07:53 AM UTC
You said Master-Details was how to set it up in 1 grid yet u sent the sample which had 2 grids. I want help regarding how to set it up in the same grid ( using hierarchy or otherwise)
>There is a section in the grid''s User''s Guide(Grid OverView - GridDataBoundGrid Use cases) describing how to set up two Mater-Detail grids.
>
Here is a minimal sample.
>
>There is another techniquer discussed in this forum thread that may be of use in particular cases. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9622
>
>
AD
Administrator
Syncfusion Team
June 24, 2004 08:19 AM UTC
Replace the formload in that sample with this formload.
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable parentTable = GetParentTable();
DataTable childTable = GetChildTable();
DataSet ds = new DataSet();
ds.Tables.AddRange(new DataTable[]{parentTable, childTable});
DataRelation parentToChild = new DataRelation("ParentToChild", parentTable.Columns["parentID"], childTable.Columns["ParentID"]);
ds.Relations.AddRange(new DataRelation[]{parentToChild});
this.gridDataBoundGrid1.DataSource = parentTable;
this.gridDataBoundGrid1.Binder.AddRelation("ParentToChild");
}
M.
M.F.K.
June 25, 2004 01:34 AM UTC
Cool, thx. Now I want to extend this by being able to show the child as datasource instead of parent on any event (for e.g. button click) and vice versa. How do i remove the plus sign if the child is the data source?
>Replace the formload in that sample with this formload.
>
>
>private void Form1_Load(object sender, System.EventArgs e)
>{
> DataTable parentTable = GetParentTable();
> DataTable childTable = GetChildTable();
> DataSet ds = new DataSet();
> ds.Tables.AddRange(new DataTable[]{parentTable, childTable});
> DataRelation parentToChild = new DataRelation("ParentToChild", parentTable.Columns["parentID"], childTable.Columns["ParentID"]);
> ds.Relations.AddRange(new DataRelation[]{parentToChild});
> this.gridDataBoundGrid1.DataSource = parentTable;
> this.gridDataBoundGrid1.Binder.AddRelation("ParentToChild");
>}
>
AD
Administrator
Syncfusion Team
June 25, 2004 06:40 AM UTC
I do not understand what you mean by the child table being the grid''s DataSource. The child Table is not set to be grid''s datasource in the above code to display the parent-child combination in a single grid.
Can you modify the sample to show what you are trying to do when you use the childtable as the datasource for the grid?
AD
Administrator
Syncfusion Team
June 25, 2004 09:56 AM UTC
Try these button handlers (after making some of teh local variables into class level members.)
private void button2_Click(object sender, System.EventArgs e)
{ //set child table
this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.DataSource = null;
this.gridDataBoundGrid1.DataMember = "";
this.gridDataBoundGrid1.Binder.ResetHierarchyLevels();
this.gridDataBoundGrid1.DataSource = this.childTable;
this.gridDataBoundGrid1.EndUpdate();
}
private void button1_Click(object sender, System.EventArgs e)
{//set parent table
this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.DataSource = null;
this.gridDataBoundGrid1.DataMember = "";
this.gridDataBoundGrid1.DataSource = this.parentTable;
this.gridDataBoundGrid1.Binder.AddRelation("ParentToChild");
this.gridDataBoundGrid1.EndUpdate();
}