Home - Forums-.NET - FlyTreeView (ASP.NET) - Templates Not Applied to Populate On Demand Nodes

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Templates Not Applied to Populate On Demand Nodes
Link Posted: 06-Nov-2006 02:54
Ideally, it would be great if you provide the sample code, that causes the problem. I've prepared a code that seems to work ok here: Page: [code]<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"ServerTemplatesTest.aspx.cs\" Inherits=\"ServerTemplatesTest\" %> <%@ Register Assembly=\"NineRays.WebControls.FlyTreeView\" Namespace=\"NineRays.WebControls\" TagPrefix=\"NineRays\" %> Untitled Page

[/code]
Link Posted: 06-Nov-2006 02:55
...  and code-behind:
using System;
using System.Data;
using NineRays.WebControls;

public partial class ServerTemplatesTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        flyTreeView.Nodes[0].ChildNodes.Clear();
        flyTreeView.Nodes[0].PopulateNodesOnDemand = true;
    }

    protected void flyTreeView_PopulateNodes(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e)
    {
        FlyTreeNode ftn = new FlyTreeNode(\"Text\", \"Value2\");
        ftn.NodeTypeID = \"interest\";
        e.Node.ChildNodes.Add(ftn);
    }
}


If possible, please modify the code in the way you're using FlyTreeView to work with server templates.
Link Posted: 06-Nov-2006 22:44
Will take me a little while to provide you an example as I'm programatically choosing between several templates based on the result of a database search, with the templates reading several node attributes to display values. I want to provide you with the smallest self contained example I can that causes the problems I'm getting.

I have a couple of deadlines to hit and then I'll get on it later this week.

Thanks again...
Link Posted: 07-Nov-2006 23:10
Here is an example which causes the problem. When you run the page, click the SEARCH button to fill some dummy values. Then expand any of the nodes. Then click the SEARCH button again. When you next expand a node all the fun will begin! Regards... aspx [code] <%@ Register Assembly=\"NineRays.WebControls.FlyTreeView\" Namespace=\"NineRays.WebControls\" TagPrefix=\"NineRays\" %> Untitled Page
'> ' Text=\"::Add Location\"/> '> ' Text=\"::Add Role\"/>
[/code]
Link Posted: 07-Nov-2006 23:12
and the code behind...


using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NineRays.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        resetNodes();
    }

    //clear all tree nodes (except root) and refill
    private void resetNodes()
    {
        FlyTreeView1.Nodes[0].ChildNodes.Clear();
        NewFillOrganisations(FlyTreeView1.Nodes[0]);
    }

    protected void FlyTreeView1_PopulateNodes(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e)
    {
        switch (e.Node.Level)
        {
            case 0:
                NewFillOrganisations(e.Node);
                break;
            case 1:
                NewFillLocations(e.Node);
                break;
        }
    }

    private void NewFillOrganisations(FlyTreeNode parent)
    {
        for (int count = 0; count < 5; count++)
        {
            FlyTreeNode node = new FlyTreeNode();
            string nodeText = \"Company number \" + count;
            node.Value = count.ToString();
            node.Attributes.Add(\"Name\", nodeText);
            node.NodeTypeID = \"CompanyViewEdit\";
            node.PopulateNodesOnDemand = true;
            node.CanBeSelected = true;
            parent.ChildNodes.Add(node);
        }
    }

    private void NewFillLocations(FlyTreeNode parent)
    {
        for (int count = 0; count < 5; count++)
        {
            FlyTreeNode node = new FlyTreeNode();
            string nodeText = \"Location number \" + count;
            node.Value = count.ToString();
            node.Attributes.Add(\"Name\", nodeText);
            node.NodeTypeID = \"LocationViewEdit\";
            node.PopulateNodesOnDemand = true;
            node.CanBeSelected = true;
            parent.ChildNodes.Add(node);
        }
    }
}
Link Posted: 08-Nov-2006 01:02
Yes, the Clear() method was not completely fixed.
Please try out the latest version available at Download page.

Thank you!
Link Posted: 08-Nov-2006 01:58
5 minutes of using v4.1.3.175 and all looks good so far!

Many thanks...