Zeb-ur-Rehman
Zeb-ur-Rehman

Reputation: 1209

Show selected element in Telerik MVC TreeView

this is the code where i create tree in telerik mvc. Now i want to create popup which shows the slected node name.

Html.Telerik().TreeView()
    .Name("ZebTree")
    .ExpandAll(true)
    .ClientEvents(events => events.OnSelect("TreeView_onSelect"))
    .BindTo(Model , map =>
            {
                map.For<TreeViewBind.Models.Category>(bind => bind.ItemDataBound((item, category) => { item.Text = category.CategoryName; }).Children(category => category.Products));
                map.For<TreeViewBind.Models.Product>(bind => bind.ItemDataBound((item, product) => { item.Text = product.ProductName;}));
            }        
    )

Here is the javascript code.

function TreeView_onSelect(e) 
    {
        var treeview = $(this).data('tTreeView');

        alert("You select the node " + ...);

    }

Upvotes: 0

Views: 1301

Answers (1)

Rustam
Rustam

Reputation: 746

to get a node's text:

function TreeView_onSelect(e) 
{
  var treeview = $(this).data('tTreeView');
  var nodeText = treeview.getItemText(e.item);
  alert("You select the node: " + nodeText);
}

Regards

Upvotes: 1

Related Questions