TreeViewNode Inlinetemplate

2 posts, 1 answers
  1. Denis
    Denis avatar
    2 posts
    Member since:
    Oct 2014

    Posted 08 Oct 2014 Link to this post

    I am trying to create nodes with template that includes  @Ajax.ActionLink  :

                                .BindTo(Model, (Kendo.Mvc.UI.Fluent.NavigationBindingFactory<TreeViewItem> mappings) =>
                                    mappings.For<myspace_menu>(bound => bound.ItemDataBound((node, myspace_menu) =>

                                        bool isaco = myspace_menu.controller.Length > 0;
                                        node.Text = myspace_menu.label;
                                        node.ImageUrl = isaco ? Url.Content("~/img/act.png") : Url.Content("~/img/folder.png");
                                        if (isaco)

                                            node.Template.InlineTemplate = @<text>@Ajax.ActionLink(myspace_menu.label, "uberitem", 
                                            new { c= myspace_menu.controller, a=myspace_menu.action },
                                            new AjaxOptions
                                                              HttpMethod = "POST",
                                                              InsertionMode = InsertionMode.Replace,
                                                              UpdateTargetId = "accessconfig"

                                    .Children(e => e.items));


    This actually works - asynchronously updates  "accessconfig" div.
    problem 1:  Instead of POST  it does GET (but I don't run any javascript and have unobtrusive referenced and enabled ).
    problem 2 - main one:   inlinetemplate content (link) looks like CHILD node of node I added it into  instead of normal appearance (see attached picture).

    Also, note I tried version with javascript onselect - it works, but I need to have ajax.ActionLink  there.
    How can I make inlinetemplate work with Ajax.Actionlink ? How make a link appear as a node text?

    thank you !


  2. Answer
    Daniel avatar
    2231 posts

    Posted 10 Oct 2014 Link to this post


    I am not sure what could be causing a GET request to be made instead of POST. Is a POST request made when using the action link outside of the treeview? If yes, then could you provide a runnable sample?
    As for the content - you should append the ActionLink to the Text property and disable the node encoding in order to show the link in the node text:
    node.Text = myspace_menu.label +
        Ajax.ActionLink(myspace_menu.label, "uberitem",
            new { c= myspace_menu.controller, a=myspace_menu.action },
            new AjaxOptions
                              HttpMethod = "POST",
                              InsertionMode = InsertionMode.Replace,
                              UpdateTargetId = "accessconfig"
    node.Encoded = false;

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top