ASP.NET C#, Infragistics 3.5 v11.1
I'm looking for help to understand what I'm missing, or a great code example. This code works with a standard MS DataTree.
My source hierarchical data is SQL2008 table using hierarchyid datatype, not parent/child columns, and I need to populate a webdatatree. (Does Infragistics support hierarchyid data type via WHDS or have suggestions on how to consume hierarchyid data?)
I'm trying to build a webdatatree without a webhierarchicaldatasource, instead building out nodes using a manual load-on-demand method. The following code loads just the notes off the root, however I cannot seem to get the expand/collapse to appear, which I believe I need in order to fire the TreeNodePopulate event to build the descendant level. I thought setting the Populated property would do this.
Here's the output, a list of level 1 items:
<ig:WebDataTree ID="wdtTree" runat="server" Height="300px" Width="200px" StyleSetName="LucidDream" OnNodePopulate="wdtTree_TreeNodePopulate" EnableConnectorLines="True" InitialExpandDepth="0" EnableExpandOnClick="True" InitialDataBindDepth="0" CssClass="Treepadding" Font-Size="Small" onnodeclick="wdtTree_NodeClick" > </ig:WebDataTree>
private void PopulateRootLevel() {
DataTable dt = new DataTable(); dt = Topics.GetMultipleAsDataTable(); dt.DefaultView.RowFilter = "TopicLevel = 1"; dt = dt.DefaultView.ToTable(); DataTreeNodeCollection nodes = wdtTree.Nodes; foreach (DataRow dr in dt.Rows) { DataTreeNode dtn = new DataTreeNode(); dtn.Text = dr["TopicName"].ToString(); dtn.Value = dr["TopicNode"].ToString(); dtn.Populated = true; dtn.Expanded = false; nodes.Add(dtn); }
}
Thanks for the help.
Jon
Thanks,
That worked!
Hello Jon,
You are missing the IsEmptyParent = "true" part
dtn.IsEmptyParent = true;
Please take a look at the online sample about Manual Load On Demand, there this part is implemented in the NodeBound event
http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/ManualLoadOnDemand/Default.aspx?cn=data-tree&sid=c257cd9c-1c5a-4159-aa51-ff8ea8386395
Let me know if you need further assistance.