I want to know how i can Add a node in the Q2 version. I saw this is one of the evolution of this version but I can't find any example...
Could you show me how can I use it ?
I want to apologize about my poor-english...
Rémy
5 Answers, 1 is accepted
The API for adding/removing nodes was introduced in 2012.Q1 and is not available previous releases. If you need to use it, you should upgrade. The API itself is demonstrated in the TreeView / client-side API example.
Regards,Alex Gyoshev
the Telerik team
But I forgot to say I am using Razor language... I can see example about Adding Node in ASPX part but not in Razor Part.
And on ASPX part, we can add a node, but just on level 0. Is it possible to add in child ?
Yes, we have an updated example that will be uploaded with the next release. You can supply the parent node for the added element as a parameter to the append/insert functions:
// append a new item to `foo`
treeview.append({ Text: "bar" }, treeview.findByText("foo"));
For more information, refer to the TreeView client API documentation.
All the best,Alex Gyoshev
the Telerik team
I have a last question :
When I want to edit a node in the tree, I have to open a window containing the node's informations and I want to "rebind" (or something like that) the tree (without reload the page) when I submit the editing form.
I use treeview like this :
@(Html.Telerik().TreeView() .Name("TreeView") .BindTo(Model, mappings => mappings.For<AssociationCategoryChildModel>(binding => binding.ItemDataBound((item, category) => { item.Value = category.Id.ToString(); item.Text = category.Name; } ) .Children(category => category.ChildCategory))) .ClientEvents(events => events .OnSelect("onSelect") .OnExpand("Expand") .OnCollapse("Collapse") ) )
In order to rebind the treeview without reloading the page, you'll need to use AJAX binding (you can use it alongside the server binding that you have in place). You can see various ways to setup the AJAX binding in the treeview / load on demand online example. After setting it up, you can use the ajaxRequest client-side method to rebind the whole treeview, or only the parent node of the edited node.
Kind regards,Alex Gyoshev
the Telerik team