C# , ASP.Net 3.5, Infragistics 11.1
I have a WebDataTree built without using a webhierarchicaldatasource and I would like to use a template for the nodes to change the way the image and text are displayed. I've used the smart tag to create a template, but I'm unable to use the <%# (Eval("Text")) %> a tags to display data because I'm not binding a data source. If I use a template similar to the one below, how to I set node values,imageurl, and text in C# code behind? I've tried accessing the controls to set values but can't seem to figure out how to get to them.
<ig:WebDataTree ID="wdtTree" runat="server" Height="600px" Width="400px" OnNodePopulate="wdtTree_TreeNodePopulate" EnableConnectorLines="True" OnNodeDropped="wdtTree_OnNodeDropped"> <DragDropSettings EnableDragDrop="True"> </DragDropSettings> <Templates> <ig:ItemTemplate ID="wdtTreeTemplate1" runat="server" TemplateID="NodesTemplate"> <Template> <asp:Image runat="server" ID="NodeImage" /> <asp:Label runat="server" ID="lblNodeText" Text=""></asp:Label> </Template> </ig:ItemTemplate> </Templates> </ig:WebDataTree>
Thanks,
Jon
Hello jpjosue ,
I've created a support case regarding your issue with number:CAS-72337-TTHWRF. We'll continue communication through there.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
The problem I have is that my hierarchical data is stored using the hierarchyid method, not parent child columns, and even if I supply node and parent node columns to the WHDS , it doesn't render the webdatatree. I had already implemented what Rob suggested above and it works ok, but needs customizing to meet my requirements.
I'm going to contact Infragistics developer support and go from there.
Currently there's no way to alter the default way to display a node.
Still both suggestions mentioned are possible. You could either use a template and access its item and do the changes to them(You need to do this after the Page_load event since you need to be sure that the template has been loaded). You can also take the approach that Rob Hudson suggested and just set the node’s text to the html <img> tag to show the desired image.
I would advise you to DataBind the Nodes to a DataSource since many of the DataTree’s events don’t fire as expected if you don’t.
Thanks, I'll try this later today. Essentially I'm just looking to be able to, for example, add additional icons to the right side of the node text that would be used as indicators, or to place a div around the left hand image (ImageURL) to to fix the left hand alignment of the Node Text where image widths are not the same(see below). Do I need a template for this, or is there a way to alter the default way a node is displayed?
Another possible solution would be if you get them thought the PreRender event like this:
protected void wdtTree_PreRender(object sender, EventArgs e)
{
DataTreeNode item = wdtTree.Nodes[0];
item.EnsureTemplate();
Label label = (Label)item.FindControl("lblNodeText");
Image img = (Image)item.FindControl("NodeImage");
}
It would be more convenient to get them on an earlier stage for example in some of the raised events but if you’re manually adding the nodes not all of the events for the tree will fire(NodeBound, TreeNodePopulate, NodeAdded).
Let me know if you need further assistance with this issue.