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();
Hello,
I think the problem here is calling AccessTreeView.DataBind() immediately after adding the node. The treeview supports bound and unbound modes - adding nodes directly to the controls collection is unbound mode, while calling DataBind() is bound mode and expects setting DataSource or DataSourceID properties. Calling DataBind() with empty DataSource/DataSourceID essentially clears the nodes.
I think if you are adding nodes directly to the nodes collection, you do not need to call DataBind() so removing the line should hopefully address the problem.
Thanks. I tried commenting that line out but it makes not difference.
Could this be something to do with images or something? I'm only using text at the moment. The version of the UltraWebNavigator is 7.3.20073.38 could that have something to do with it?
From what I see, I really do not see where the poblem originates. Maybe it is something in project or page setup, or the PopupContainer that I see you are using inteferes in some way.
I believe in these cases, where problems are tough to find, the best approach is to assemble a small subset of your project reproducing the problem and send it to our dedicated Developer Support department via this link:
http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx
Some info on environment (browser, VS.NET / .NET version, etc) will also help them repro the problem and advice further.
HTH,
I made test app with the same code and it works fine. The problem seems to be something specific to the popup control. I'll investigate further. The popup control is a standard AjaxControlToolkit modal popup extender.
For now I am just using the tree view on a normal page but I will have to move it to a popup later.
I've got another problem now. When the page is loaded for the first time, the first node displays correctly. I expand the node and it correctly loads two chidren. However, when I expand one of those nodes, it clears out the tree altogeher. Here is all my code:
var rootAccessGroups = GetChildAccessGroups(0);
AccessTreeView.Nodes.Add( NewNode(accessGroup.Name, accessGroup.AccessGroupKey));
accessGroupNode.Text = name;
accessGroupNode.DataKey = key;
accessGroupNode.Checked = true;
e.Node.Nodes.Add(NewNode(childAccessGroup.Name, childAccessGroup.AccessGroupKey));
Here's a very simple app which has the same problem:
CompactRendering="False" EnableViewState="False" SingleBranchExpand="True" 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>
public partial class _Default : System.Web.UI.Page
accessGroupNode.DataKey = "1";
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">
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?