Nodes Does Not Show Up

This post has 12 Replies | 2 Followers

AdaptSolutions
Points 385
Replied On: Tue, Sep 23 2008 7:16 PM

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">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

</Styles>

</ignav:UltraWebTree>

This is my Page_Load code:

var AccessControlPopup = (PopupControl)RecordFormView.FindControl("AccessControlPopup");

var AccessTreeView = (UltraWebTree)AccessControlPopup.FindControl("AccessTreeView");

AccessTreeView.Visible = true;

var rootAccessGroups = GetChildAccessGroups("0");foreach (var accessGroup in rootAccessGroups)

{

var accessGroupNode = AccessTreeView.Nodes.Add(accessGroup.Name);

accessGroupNode.DataKey = accessGroup.AccessGroupKey.ToString();

accessGroupNode.ShowExpand =
true;

}

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:

protected void AccessTreeView_DemandLoad(object sender, WebTreeNodeEventArgs e)

{

foreach (var childAccessGroup in GetChildAccessGroups((string)e.Node.DataKey))

{

var childAccessGroupNode = e.Node.Nodes.Add(childAccessGroup.Name);

childAccessGroupNode.DataKey = childAccessGroup.AccessGroupKey.ToString();

childAccessGroupNode.ShowExpand =
true;

}

}

  • Post Points: 20
Replied On: Wed, Sep 24 2008 3:45 AM

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.

Best Regards,

Rumen Stankov (MCSD.NET)

Infragistics Inc.

  • Post Points: 20
AdaptSolutions
Points 385
Replied On: Wed, Sep 24 2008 4:01 AM

Thanks. I tried commenting that line out but it makes not difference.

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Wed, Sep 24 2008 6:54 PM

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?

  • Post Points: 20
Replied On: Thu, Sep 25 2008 5:44 AM

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,

Best Regards,

Rumen Stankov (MCSD.NET)

Infragistics Inc.

  • Post Points: 20
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 12:06 AM

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.

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 1:56 AM

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:

protected void Page_Load(object sender, EventArgs e)

{

AccessTreeView.Visible =
true;

var rootAccessGroups = GetChildAccessGroups(0);

foreach (var accessGroup in rootAccessGroups)

{

AccessTreeView.Nodes.Add( NewNode(accessGroup.Name, accessGroup.AccessGroupKey));

}

}

private Node NewNode(string name, int key)

{

var accessGroupNode = new Node();

accessGroupNode.Text = name;

accessGroupNode.DataKey = key;

accessGroupNode.ShowExpand =
true;

accessGroupNode.Checked = true;

accessGroupNode.Enabled = true;return accessGroupNode;

}

protected void AccessTreeView_DemandLoad(object sender, WebTreeNodeEventArgs e)

{

foreach (var childAccessGroup in GetChildAccessGroups((int)e.Node.DataKey))

{

e.Node.Nodes.Add(NewNode(childAccessGroup.Name, childAccessGroup.AccessGroupKey));

}

}

private List<AccessGroup> GetChildAccessGroups(int parentAccessGroupKey)

{

return Util.GetSecurityService().GetAccessGroupsByColumnValue(AccessGroup.ColumnParentAccessGroup, parentAccessGroupKey, null);

}

private List<AccessItem> GetChildAccessItems(int parentAccessGroupKey)

{

return Util.GetSecurityService().GetAccessItemsByColumnValue(AccessItem.ColumnAccessGroup, parentAccessGroupKey, null);

}

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 2:15 AM

Here's a very simple app which has the same problem:

 

<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>

<ignav:Level Index="2"></ignav:Level>

<ignav:Level Index="3"></ignav:Level>

<ignav:Level Index="4"></ignav:Level>

<ignav:Level Index="5"></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">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

</Styles>

</ignav:UltraWebTree>

 

 

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

var accessGroupNode = AccessTreeView.Nodes.Add("test");

accessGroupNode.DataKey = "1";

accessGroupNode.ShowExpand = true;

accessGroupNode.Checked = true;

accessGroupNode.Enabled = true;

}

protected void AccessTreeView_DemandLoad(object sender, WebTreeNodeEventArgs e)

{

var childAccessGroupNode = e.Node.Nodes.Add("Child");childAccessGroupNode.ShowExpand = true;

 

}

 

}

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 2:16 AM

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?

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 2:49 AM

OK. The problems that I have stated here have been solved. I must have picked up the wrong ASP code somewhere. This ASP works:

<ignav:UltraWebTree ID="AccessTreeView" runat="server" Cursor="Default" ForeColor="Black"

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">

<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>

<ignav:Level Index="2"></ignav:Level>

<ignav:Level Index="3"></ignav:Level>

<ignav:Level Index="4"></ignav:Level>

<ignav:Level Index="5"></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">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

</Styles>

</ignav:UltraWebTree>

  • Post Points: 5
AdaptSolutions
Points 385
Replied On: Fri, Sep 26 2008 2:53 AM

But! Here's a new problem. This is my code:

private const string ViewState_Level = "ViewState_Level";protected void Page_Load(object sender, EventArgs e)

{

var accessGroupNode = AccessTreeView.Nodes.Add("test");

accessGroupNode.DataKey = "1";

accessGroupNode.ShowExpand = true;

accessGroupNode.Checked = true;accessGroupNode.Enabled = true;

 

ViewState[ViewState_Level] = 0;

}

protected void AccessTreeView_DemandLoad(object sender, WebTreeNodeEventArgs e)

{

var bla = ((int)ViewState[ViewState_Level])+1;var childAccessGroupNode = e.Node.Nodes.Add("Child");

childAccessGroupNode.DataKey = bla;

childAccessGroupNode.ShowExpand =
true;

}

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.

  • Post Points: 20
Replied On: Mon, Sep 29 2008 11:50 AM

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

Best Regards,

Rumen Stankov (MCSD.NET)

Infragistics Inc.

  • Post Points: 20
AdaptSolutions
Points 385
Replied On: Mon, Sep 29 2008 6:06 PM

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">

<ignav:UltraWebTree ID="AccessTreeView" runat="server" Cursor="Default" ForeColor="Black"

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" >

<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>

<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">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

</Styles>

</ignav:UltraWebTree>

</igmisc:WebAsyncRefreshPanel>

  • Post Points: 25
Page 1 of 1 (13 items) | RSS