I am trying to figure out how this works, so I created an example to work with. This example is creating two tables in a parent/child relationship in a dataset and binding the dataset to an EpiUltraGrid. I am using ExpandAll on the grid. But I only see the parent table in the grid. (I know UD102 and UD102A are already setup in a parent/child relationship, but I wanted to test this from any two tables. I’m just using UD102 and UD102A to populate the tables)
Why is the child data not showing up in the grid?
private void LoadLayouts(string Part)
{
//Build a table to hold the parents
DataTable Parents = new DataTable();
Parents.Columns.Add("Layout", System.Type.GetType("System.String"));
Parents.Columns.Add("PurStk", System.Type.GetType("System.String"));
Parents.Columns.Add("PartNum", System.Type.GetType("System.String"));
Parents.Columns.Add("Width", System.Type.GetType("System.Double"));
Parents.Columns.Add("Length", System.Type.GetType("System.Double"));
Parents.Columns.Add("Whse", System.Type.GetType("System.String"));
Parents.Columns.Add("Bin", System.Type.GetType("System.String"));
Parents.Columns.Add("Lot", System.Type.GetType("System.String"));
var keys = new DataColumn[2];
keys[0] = Parents.Columns[0];
keys[1] = Parents.Columns[1];
Parents.PrimaryKey = keys;
//Build a table to hold the plate children
DataTable Children = new DataTable();
Children.Columns.Add("Layout", System.Type.GetType("System.String"));
Children.Columns.Add("PurStk", System.Type.GetType("System.String"));
Children.Columns.Add("Reserve", System.Type.GetType("System.String"));
Children.Columns.Add("Revision", System.Type.GetType("System.String"));
Children.Columns.Add("PlateID", System.Type.GetType("System.String"));
Children.Columns.Add("Serial", System.Type.GetType("System.String"));
Children.Columns.Add("Width", System.Type.GetType("System.Double"));
Children.Columns.Add("Length", System.Type.GetType("System.Double"));
Children.Columns.Add("xPos", System.Type.GetType("System.Int32"));
Children.Columns.Add("yPos", System.Type.GetType("System.Int32"));
Children.Columns.Add("PartNum", System.Type.GetType("System.String"));
Children.Columns.Add("Shape", System.Type.GetType("System.String"));
Children.Columns.Add("Domestic", System.Type.GetType("System.String"));
var keys2 = new DataColumn[2];
keys2[0] = Children.Columns[0];
keys2[1] = Children.Columns[1];
Children.PrimaryKey = keys2;
//Get the layouts from a baq
string baqID = "DTSF-PlateReserveLayouts";
DynamicQueryAdapter DQAdpt = new DynamicQueryAdapter(UD101Form);
DQAdpt.BOConnect();
Ice.BO.QueryExecutionDataSet execSet = DQAdpt.GetQueryExecutionParametersByID(baqID);
execSet.ExecutionParameter.Clear();
execSet.ExecutionParameter.AddExecutionParameterRow("PartNum", Part, "nvarchar", false, Guid.NewGuid(), "A");
DQAdpt.ExecuteByID(baqID, execSet);
DataTable ParentTbl = DQAdpt.QueryResults.Tables["Results"];
//Add the parents to the parent table
foreach(DataRow pRow in ParentTbl.Rows)
{
DataRow newRow = Parents.NewRow();
newRow["Layout"] = pRow["UD102_Key1"].ToString();
newRow["PurStk"] = pRow["UD102_Key2"].ToString();
newRow["PartNum"] = pRow["UD102_ShortChar01"].ToString();
newRow["Width"] = Convert.ToDouble(pRow["UD102_Number02"].ToString());
newRow["Length"] = Convert.ToDouble(pRow["UD102_Number03"].ToString());
newRow["Whse"] = pRow["UD102_ShortChar02"].ToString();
newRow["Bin"] = pRow["UD102_ShortChar03"].ToString();
newRow["Lot"] = pRow["UD102_ShortChar04"].ToString();
Parents.Rows.Add(newRow);
}
//Cycle through each parent to get their children
foreach(DataRow dRow in ParentTbl.Rows)
{
string Layout = dRow["UD102_Key1"].ToString();
//Get the children from a baq
string baqID2 = "DTSF-PlateReserveLayoutsChild";
DynamicQueryAdapter DQAdpt2 = new DynamicQueryAdapter(UD101Form);
DQAdpt2.BOConnect();
Ice.BO.QueryExecutionDataSet execSet2 = DQAdpt2.GetQueryExecutionParametersByID(baqID2);
execSet2.ExecutionParameter.Clear();
execSet2.ExecutionParameter.AddExecutionParameterRow("Layout", Layout, "nvarchar", false, Guid.NewGuid(), "A");
DQAdpt2.ExecuteByID(baqID2, execSet2);
DataTable ChildTbl = DQAdpt2.QueryResults.Tables["Results"];
//Add each child to the child table
foreach(DataRow cRow in ChildTbl.Rows)
{
DataRow newRow = Children.NewRow();
newRow["Layout"] = cRow["UD102A_Key1"].ToString();
newRow["PurStk"] = cRow["UD102A_Key2"].ToString();
newRow["Reserve"] = cRow["UD102A_ChildKey1"].ToString();
newRow["Revision"] = cRow["UD102A_ChildKey2"].ToString();
newRow["PlateID"] = cRow["UD102A_ChildKey3"].ToString();
newRow["Serial"] = cRow["UD102A_ChildKey4"].ToString();
newRow["Width"] = Convert.ToDouble(cRow["UD102A_Number02"].ToString());
newRow["Length"] = Convert.ToDouble(cRow["UD102A_Number03"].ToString());
newRow["xPos"] = Convert.ToInt32(Convert.ToDouble(cRow["UD102A_Number04"].ToString()));
newRow["yPos"] = Convert.ToInt32(Convert.ToDouble(cRow["UD102A_Number05"].ToString()));
newRow["PartNum"] = cRow["UD102A_ShortChar01"].ToString();
newRow["Shape"] = cRow["UD102A_ShortChar02"].ToString();
newRow["Domestic"] = cRow["UD102A_ShortChar03"].ToString();
Children.Rows.Add(newRow);
}
}
//Put both tables in a dataset
DataSet UD102DS = new DataSet();
UD102DS.Tables.Add(Parents);
UD102DS.Tables.Add(Children);
//Create a relationship between the tables
UD102DS.Relations.Clear();
DataColumn ParentColumn = UD102DS.Tables[0].Columns[0];
DataColumn ChildColumn = UD102DS.Tables[1].Columns[0];
DataRelation DataRelationShip = new DataRelation("ParentsChildren", ParentColumn, ChildColumn );
UD102DS.Relations.Add(DataRelationShip);
//Add the dataset as the datasource for the grid
LayoutsGrid.DataSource = UD102DS;
LayoutsGrid.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.MultiBand;
LayoutsGrid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
LayoutsGrid.DisplayLayout.Bands[0].SortedColumns.Add("Layout", false, true);
LayoutsGrid.Rows.ExpandAll(true);
}