Copied to clipboard

Flag this post as spam?

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


  • atze187 160 posts 215 karma points
    Aug 11, 2010 @ 08:10
    atze187
    0

    Custom tree and node actions

    Hi,

    we are starting to port our code to v4.5 and I found that the overridden RenderJS method in my tree is not getting executed, so did I miss something on how to register custom js code containing the functions that are called when clicking on a treenode?

    Thanks,
    atze

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 11, 2010 @ 08:24
    Richard Soeteman
    0

    Hi,

    You need to create Unique JS Functions for a tree and for the actions you nmeed to specify The Javascript function in the JSSource property and then call that function by implementing the JSFunctionName property.

    This didn't work in 4.0. I've blogged about this a few months back

    When you are developing the tree and want to test it you have to log out and login again to get the tree to render.

    Hope this helps you,

    Richard

  • atze187 160 posts 215 karma points
    Aug 11, 2010 @ 08:48
    atze187
    0

    So I get you right that I need to create completely custom actions for my tree, right?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 11, 2010 @ 08:54
    Richard Soeteman
    0

    You have to create unique Javascript methods yes.

  • atze187 160 posts 215 karma points
    Aug 11, 2010 @ 09:14
    atze187
    0

    Sorry, I lack a little sleep ;) So, to create those unique JS methods, I need to implement my custom actions using the IAction interface?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 11, 2010 @ 09:19
    Richard Soeteman
    0

    If you are using Node action yes. Otherwise only make sure that your Javascript method is unique. Below an example how I Use it in my TaskScheduler package

     

    /// <summary>

     

    /// Create Javascript element that provides functionality to display the page

     

    /// </summary>

     

    /// <param name="Javascript"></param>

     

    public override void RenderJS(ref StringBuilder Javascript)

    {

     

    base.RenderJS(ref Javascript);

    Javascript.Append(

    @"function openScheduleUrl(url){

    parent.right.document.location.href = url;

    }"

     

    );

    }

     

    /// <summary>

     

    /// Create Menu based on the Dropdowns.config xml file

     

    /// </summary>

     

    public override void Render(ref XmlTree tree)

    {

     

    //Render submenu

     

    string executeOption = Enum.GetName(typeof(ExecuteOptions), int.Parse(NodeKey));

     

    List<ScheduledTaskType> menuItems = DAL.ScheduledTask.GetSavedItemsForMenu(executeOption);

     

    foreach (ScheduledTaskType menuItem in menuItems)

    {

     

    string icon = "../editor/calendar.gif";

     

    XmlTreeNode node = XmlTreeNode.Create(this);

    node.NodeID = menuItem.ScheduledTaskId.ToString();

    node.NodeType =

    "ScheduledTasks";

    node.Text = menuItem.Taskname;

    node.Action =

    "javascript:openScheduleUrl('" + string.Format("{0}?scheduledtaskid={1}",UrlHelper.MakeUrlAbsolute("/plugins/TaskScheduler/Pages/ScheduleTask.aspx"), node.NodeID) + "');";

    node.Icon = icon;

    node.OpenIcon = icon;

    tree.Add(node);

    }

    }

     
  • atze187 160 posts 215 karma points
    Aug 11, 2010 @ 10:58
    atze187
    0

    Sorry, I mixed up actions, that are executed through context menu and the node.Action assigned to the node created in the Render method. Plus the RenderJS was not executed, which was due to a code snippet I copied from the source and which had several integrity checks on properties I don't need.

    Sry for that. But thanks for clarification on differences between 4.0.x and 4.5+.

Please Sign in or register to post replies

Write your reply to:

Draft