Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kasper 9 posts 29 karma points
    Aug 04, 2010 @ 15:35
    Kasper
    0

    Custom tree and section - Text duplicate issue

    Hi Everyone

    Hope you can help me solve this issue, i have created 2 new section with custom trees,

    But when i press the section link the tree nodes of that section duplicates its self, i have no clue to what the problem is.

    Screendump

     

    Code

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    public class loadProductsTreeNodes :

    BaseTree

    {

     

    public loadProductsTreeNodes(string

    application) :

     

    base

    (application) { }

     

     

    protected override void CreateRootNode(ref XmlTreeNode

    rootNode)

    {

    rootNode.Icon = FolderIcon;

    rootNode.OpenIcon = FolderIconOpen;

    rootNode.NodeType =

     

    "init"

    + TreeAlias;

    rootNode.NodeID =

     

    "init"

    ;

    }

     

    public override void Render(ref XmlTree

    Tree)

    {

     

     

    var NewProduct = XmlTreeNode.Create(this

    );

    NewProduct.Text =

     

    "Opret produkt"

    ;

    NewProduct.Icon =

     

    "add_product_icon.gif"

    ;

    NewProduct.Action =

     

    "javascript:openAddProducts()"

    ;

    NewProduct.Menu =

     

    null

    ;

     

    // Add the node to the tree

     

    if

    (Tree.treeCollection.Contains(NewProduct))

    {

    }

     

    else

    {

    Tree.Add(NewProduct);

    }

     

    var EditProduct = XmlTreeNode.Create(this

    );

    EditProduct.Text =

     

    "Rediger/slet produkt"

    ;

    EditProduct.Icon =

     

    "edit_product_icon.gif"

    ;

    EditProduct.Action =

     

    "javascript:openEditProducts()"

    ;

    EditProduct.Menu =

     

    null

    ;

     

    // Add the node to the tree

     

    if

    (Tree.treeCollection.Contains(EditProduct))

    {

    }

     

    else

    {

    Tree.Add(EditProduct);

    }

    }

     

    public override void RenderJS(ref StringBuilder

    Javascript)

    {

    Javascript.Append(

     

    @"

    function openAddProducts() {

    parent.right.document.location.href = 'Plugins/products/addProduct.aspx';

    }

    "

     

     

    );

    Javascript.Append(

     

    @"

    function openEditProducts() {

    parent.right.document.location.href = 'Plugins/products/editProduct.aspx';

    }

    "

     

     

    );

     

    Database

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Aug 05, 2010 @ 10:52
    Morten Christensen
    0

    Hi Kasper,

    Can I get you to put the code in a code block like:

    public class loadProductsTreeNodes : BaseTree
    {}

    It makes a little easier to get an overview of your code.

    Thanks,

    - Morten

  • Kasper 9 posts 29 karma points
    Aug 05, 2010 @ 12:30
    Kasper
    0

     

     

    here you go :) hope it helps me find a solution.

    I have 2 Tree nodes classes

    loadOrdersTreeNodes.cs
    loadProductsTreeNodes.cs

     

    public class loadOrdersTreeNodes : BaseTree

    {

     

    public loadOrdersTreeNodes(string application)

    :

    base(application)

    { }

     

     

    protected override void CreateRootNode(ref XmlTreeNode rootNode)

    {

    rootNode.Icon = FolderIcon;

    rootNode.OpenIcon = FolderIconOpen;

    rootNode.NodeType =

    "init" + TreeAlias;

    rootNode.NodeID =

    "init";

    }

     

     

    public override void Render(ref XmlTree Tree)

    {

    Tree.treeCollection.Clear();

     

    var newOrder = XmlTreeNode.Create(this);

    newOrder.Text =

    "Nye Bestillinger";

    newOrder.Icon =

    "new_orders_icon.gif";

    newOrder.Action =

    "javascript:openNewOrders()";

    newOrder.Menu =

    null;

     

    // Add the node to the tree

     

    if (Tree.treeCollection.Contains(newOrder))

    {

     

    }

     

    else

    {

    Tree.Add(newOrder);

    }

     

     

     

    var waitingOrders = XmlTreeNode.Create(this);

    waitingOrders.Text =

    "Bestillinger venter afsendelse";

    waitingOrders.Icon =

    "waiting_orders_icon.gif";

    waitingOrders.Action =

    "javascript:openWaitingOrders()";

    waitingOrders.Menu =

    null;

     

    // Add the node to the tree

     

    if (Tree.treeCollection.Contains(waitingOrders))

    {

    }

     

    else

    {

    Tree.Add(waitingOrders);

    }

     

     

    var OldOrders = XmlTreeNode.Create(this);

    OldOrders.Text =

    "Gennemfrte bestillinger";

    OldOrders.Icon =

    "old_orders_icon.gif";

    OldOrders.Action =

    "javascript:openOldOrders()";

    OldOrders.Menu =

    null;

     

    // Add the node to the tree

     

    if (Tree.treeCollection.Contains(OldOrders))

    {

    }

     

    else

    {

    Tree.Add(OldOrders);

    }

    }

     

    public override void RenderJS(ref StringBuilder Javascript)

    {

    Javascript.Append(

    @"

    function openNewOrders() {

    parent.right.document.location.href = 'Plugins/orders/newOrders.aspx';

    }

    "

     

    );

    Javascript.Append(

    @"

    function openWaitingOrders() {

    parent.right.document.location.href = 'Plugins/orders/waitingOrders.aspx';

    }

    "

     

    );

    Javascript.Append(

    @"

    function openOldOrders() {

    parent.right.document.location.href = 'Plugins/orders/oldOrders.aspx';

    }

    "

     

    );

    }

     

     

     

     

     

    public loadProductsTreeNodes(string application) :

     

    base(application) { }

     

     

    protected override void CreateRootNode(ref XmlTreeNode rootNode)

    {

    rootNode.Icon = FolderIcon;

    rootNode.OpenIcon = FolderIconOpen;

    rootNode.NodeType =

    "init" + TreeAlias;

    rootNode.NodeID =

    "init";

    }

     

    public override void Render(ref XmlTree Tree)

    {

    Tree.treeCollection.Clear();

     

    var NewProduct = XmlTreeNode.Create(this);

    NewProduct.Text =

    "Opret produkt";

    NewProduct.Icon =

    "add_product_icon.gif";

    NewProduct.Action =

    "javascript:openAddProducts()";

    NewProduct.Menu =

    null;

     

    // Add the node to the tree

     

    if (Tree.treeCollection.Contains(NewProduct))

    {

    }

     

    else

    {

    Tree.Add(NewProduct);

    }

     

    var EditProduct = XmlTreeNode.Create(this);

    EditProduct.Text =

    "Rediger/slet produkt";

    EditProduct.Icon =

    "edit_product_icon.gif";

    EditProduct.Action =

    "javascript:openEditProducts()";

    EditProduct.Menu =

    null;

     

    // Add the node to the tree

     

    if (Tree.treeCollection.Contains(EditProduct))

    {

    }

     

    else

    {

    Tree.Add(EditProduct);

    }

    }

     

    public override void RenderJS(ref StringBuilder Javascript)

    {

    Javascript.Append(

    @"

    function openAddProducts() {

    parent.right.document.location.href = 'Plugins/products/addProduct.aspx';

    }

    "

     

    );

    Javascript.Append(

    @"

    function openEditProducts() {

    parent.right.document.location.href = 'Plugins/products/editProduct.aspx';

    }

    "

     

    );

    }

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Aug 05, 2010 @ 13:36
    Morten Christensen
    0

    Hi Kasper,

    Can you try to add an ID to your newOrder, waitingOrders, OldOrders etc. before adding them to the tree?

    Something like:

    var newOrder = XmlTreeNode.Create(this);
    newOrder.ID = "uniqueNewOrder";
    newOrder.Text = "Nye Bestillinger";
    newOrder.Icon = "new_orders_icon.gif";
    newOrder.Action = "javascript:openNewOrders()";
    newOrder.Menu = null;

    - Morten

  • Kasper 9 posts 29 karma points
    Aug 05, 2010 @ 14:02
    Kasper
    0

    Hi Morten

    Thank you very much!!!, it fixed my problem :D

    Cant make any sense still, cause i have another project where i create a custom tree just like my code above, and it doesn't have ID (NodeID) attribute filled out. And it works without any problems.

    Again Thank you...

    Best Regards
    Kasper L

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Aug 05, 2010 @ 14:05
    Morten Christensen
    0

    Cool! Glad it worked :)

    I think the problem was that the tree was rendering the same nodes on top of each other when loading it the second time.
    It would probably be a good idea to add IDs to your other project as well ;)

    - Morten

  • Anker 2 posts 22 karma points
    Sep 08, 2010 @ 23:06
    Anker
    0

    Hi
    I have the same problem, tryed to use 'add an ID to your newOrder, etc.', but  the .id don't exist. tryed with .NodeID, but  do not solder the problem.

    I am using umbraco 4.5.2 with .net4.0

    -Anker

  • Anker 2 posts 22 karma points
    Sep 09, 2010 @ 00:20
    Anker
    0

    Forget my larst post, it is working now.

    I have a problem with the Random string.

    -Anker

Please Sign in or register to post replies

Write your reply to:

Draft