This is my ASP code. I just took it from a sample:
<ignav:UltraWebTree ID="AccessTreeView" runat="server" Cursor="Default" ForeColor="Black"
Font-Size="8pt" Font-Names="Verdana" BorderColor="Pink" BorderStyle="Dashed" Height="400px"
Width="300px" Indentation="20" WebTreeTarget="ClassicTree" LoadOnDemand="Manual"
CompactRendering="False" EnableViewState="False" SingleBranchExpand="True" OnDemandLoad="AccessTreeView_DemandLoad">
<SelectedNodeStyle Cursor="Hand" CssClass="SelectClass"></SelectedNodeStyle>
<HoverNodeStyle Cursor="Hand" CssClass="Hover"></HoverNodeStyle>
<NodePaddings Left="5px"></NodePaddings>
<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>
<Levels>
<ignav:Level Index="0"></ignav:Level>
<ignav:Level Index="1"></ignav:Level>
</Levels>
<NodeMargins Top="2px"></NodeMargins>
<Styles>
<ignav:Style Cursor="Hand" ForeColor="Black" BackColor="OldLace" CssClass="HiliteClass">
</ignav:Style>
<ignav:Style BorderWidth="1px" BorderColor="DarkGray" BorderStyle="Solid" BackColor="Gainsboro"
CssClass="Hover">
<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">
</Styles>
</ignav:UltraWebTree>
This is my Page_Load code:
var AccessControlPopup = (PopupControl)RecordFormView.FindControl("AccessControlPopup");
AccessTreeView.Visible = true;
{
accessGroupNode.DataKey = accessGroup.AccessGroupKey.ToString();
}
AccessTreeView.DataBind();
AccessTreeView.ExpandAll();
When I step through the code, I clearly see that 1 node is being added to the collection AccessTreeView.Nodes. However, when the tree view is displayed, it is completely empty.
This is my DemandLoad code, however it is not being hit so I think it is irrelevent:
childAccessGroupNode.DataKey = childAccessGroup.AccessGroupKey.ToString();
Actually I read another article and found that what I had to do was set the tree to manual and place the tree inside a WebAsyncRefreshPanel which I'm guessing is like an ASP UpdatePanel. Here is the code.
Funny that the samples don't show how this is done.
I can't really understand why you would use the other methods of populating the tree because in the two Ajax modes, only the DataPath property is persisted to the server side. With WebAsyncRefreshPanel, all the Nodes and their properties are persisted to the server side.
My advice is to use the WebAsyncRrefreshPanel and not the other modes that the samples use; unless, you only want to do processing on the client side. But, I can't really imagine a case where you would only want to work on the client side.
<igmisc:WebAsyncRefreshPanel runat="server" ID="treeAsyncPanel" LinkedRefreshControlID="AccessTreeView"
Width="470px" Height="465px">
ExpandAnimation="AccelDecel" Font-Size="8pt" Font-Names="Verdana" BorderColor="Black"
BorderStyle="Solid" Height="460px" Width="470px" Indentation="20" WebTreeTarget="HierarchicalTree"
LoadOnDemand="Manual" CompactRendering="False" EnableViewState="True" SingleBranchExpand="false"
OnDemandLoad="AccessTreeView_DemandLoad" >
</igmisc:WebAsyncRefreshPanel>
In this mode DataKey is not supported, but you can use DataPath . I think Vince has a great post on this here:
http://forums.infragistics.com/forums/t/14122.aspx
But! Here's a new problem. This is my code:
var accessGroupNode = AccessTreeView.Nodes.Add("test");
accessGroupNode.ShowExpand = true;
ViewState[ViewState_Level] = 0;
childAccessGroupNode.DataKey = bla;
This correctly adds a node every time it is expanded. However in the DemandLoad event I find that e.Node is an empty node. And, e.Node.DataKey is null. It should be the number that I have set. Without a useful DataKey, I can't load anymore child nodes. I only get a useful e.Node the first time the nodes are expanded.
OK. The problems that I have stated here have been solved. I must have picked up the wrong ASP code somewhere. This ASP works:
Font-Size="8pt" Font-Names="Verdana" BorderColor="Pink" BorderStyle="None" Height="400px"
Width="300px" Indentation="20" WebTreeTarget="HierarchicalTree" LoadOnDemand="ManualSmartCallbacks"
CompactRendering="False" EnableViewState="True" SingleBranchExpand="False" OnDemandLoad="AccessTreeView_DemandLoad">
<ignav:Level Index="2"></ignav:Level>
<ignav:Level Index="3"></ignav:Level>
<ignav:Level Index="4"></ignav:Level>
<ignav:Level Index="5"></ignav:Level>
Also, IE makes that stupid clicking noise when I click on a node. That means that the page is refreshing. How do I stop that?