This is a migrated thread and some comments may be shown as answers.

TreeViewNode Inlinetemplate

1 Answer 78 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Denis
Top achievements
Rank 1
Denis asked on 08 Oct 2014, 04:07 PM
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










1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Oct 2014, 10:27 AM
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!
 
Tags
TreeView
Asked by
Denis
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or