I am binding a data set with 3 tables to a grid style UltraWinTree (v9.2). The structure is organized so that I have two top level 'bands' (data tables with various number of columns) and one child 'band' (another data table) underneath each top band (see picture). Both top level tables have a relationship with the same bottom level data table. Two questions:
1. How do I get rid of the root level elements in red - Table1 and Table 2?
2. How do I make sure ChildTable (child band table) does not show as a separate table on the tree? It should only show as a 'second band'
What I am trying to have here is a 'grid' where I can have various number of columns on the top band. The picture of the tree is below but I have no idea how to attach the source here. Thanks!!
exelonbsc said:its not like you can have 3 cells in one row and 5 cells in the second row - is that correct?
No, I don't think that is correct. If you set the Style to FreeForm, you can have nodes in the same colletion that have different columns (and a different number of columns). I don't think the tree will do this for you, though. You will have to generate the ColumnSet for each node and assign it to the node in your code.So it requires a bit more coding, but it should be possible if that's what you want.
Mike, I have started to move in the direction of manually adding band nodes and then binding corresponding table from the data set underneath and that approach allowed me to have the data presented minus the unneeded band nodes. I have tried using a single top level data table initially but this approach does not seem to allow for heterogeneous data structure (its not like you can have 3 cells in one row and 5 cells in the second row - is that correct? Thanks for your input.
Hi,
Those extra nodes are called Band Nodes and they will show up any time you have sibling bands. There is no way to prevent this or remove the band nodes. They must be there to separate the nodes collections of the two different bands.
If you want to show data from two different bands with no band node, then you would have to create a data source that contains a single collection of items to bind to the tree.
Or, you could, of course, populate the tree manually using the Add method on the nodes collection instead of binding. You could use the FreeForm ViewStyle and assign a different ColumnSet to each node in the tree.
This is my code that builds the data set:
private static DataSet BuildDS() { DataSet ds = new DataSet(); DataTable t1 = new DataTable("Table1"); ds.Tables.Add(t1); t1.Columns.Add(new DataColumn("Id", typeof(int))); t1.Columns.Add(new DataColumn("Column1")); t1.Columns.Add(new DataColumn("Column2")); t1.Columns.Add(new DataColumn("Column3")); DataTable t2 = new DataTable("Table2"); ds.Tables.Add(t2); t2.Columns.Add(new DataColumn("Id", typeof(int))); t2.Columns.Add(new DataColumn("Column1")); t2.Columns.Add(new DataColumn("Column2")); t2.Columns.Add(new DataColumn("Column3")); t2.Columns.Add(new DataColumn("Column4")); t2.Columns.Add(new DataColumn("Column5")); DataTable ct1 = new DataTable("ChildTable1"); ds.Tables.Add(ct1); ct1.Columns.Add(new DataColumn("ParentId", typeof(int))); ct1.Columns.Add(new DataColumn("Id", typeof(int))); ct1.Columns.Add(new DataColumn("Column1")); ct1.Columns.Add(new DataColumn("Column2")); ct1.Columns.Add(new DataColumn("Column3")); DataRow drT1 = t1.NewRow(); drT1["Id"] = 1; drT1["Column1"] = "Val1"; drT1["Column2"] = "Val2"; drT1["Column3"] = "Val3"; t1.Rows.Add(drT1); DataRow drT2 = t2.NewRow(); drT2["Id"] = 1; drT2["Column1"] = "Val1"; drT2["Column2"] = "Val2"; drT2["Column3"] = "Val3"; drT2["Column4"] = "Val4"; drT2["Column5"] = "Val5"; t2.Rows.Add(drT2); DataRow drct2 = ct1.NewRow(); drct2["ParentId"] = drT1["Id"]; drct2["Id"] = 1; drct2["Column1"] = "ChildVal1"; drct2["Column2"] = "ChildVal2"; drct2["Column3"] = "ChildVal3"; ct1.Rows.Add(drct2); ds.Relations.Add("Rel1", ds.Tables["Table1"].Columns["Id"], ds.Tables["ChildTable1"].Columns["ParentId"], false); ds.Relations.Add("Rel2", ds.Tables["Table2"].Columns["Id"], ds.Tables["ChildTable1"].Columns["ParentId"], false); return ds; }
And this is how I bind the dataset to the tree control:
private void Form1_Load(object sender, EventArgs e) { DataSet ds = null; try { ds = BuildDS(); } catch (Exception ex) { String errorMsg = "Failed to initialize the view: " + (ex.Message + ((ex.InnerException != null) ? ex.InnerException.Message : String.Empty) + ex.StackTrace); MessageBox.Show(this, errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.ultraTree1.SetDataBinding(ds, null); }