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  :

     @(Html.Kendo().TreeView()
                                .Name("actiontree")
                                .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"
                                                          })</text>;
                                        }


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

                                })
                            )  





    This actually works - asynchronously updates  "accessconfig" div.
    However
    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 !


    Denis










  2. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 10 Oct 2014 Link to this post

    Hello,

    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;


    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top