Vinit Patel
Vinit Patel

Reputation: 2464

How to use teleric treeview control in asp.net mvc framework?

I want to use telerik treeview in mvc, but i don't want to use kendo UI, and i can't fine any example of teleric treeview for mvc.

can any one help me or give me any example so i can learn and understand?

I want to use treeview with checkbox and list is like this...

{
pencil 
  *natraj
  *apsara
pen
  *bollpen
     >rotomak
     >add jel
  *Inkpen
Eraser
  *natraj
}

This type of list then how can i use teleriK treeview with mvc framework for insert and delete function?

it's relly need please give any example or sample code.

Upvotes: 1

Views: 3955

Answers (1)

Nic
Nic

Reputation: 1089

Sample code:

@model YourModelTree
     @(Html.Telerik().TreeView()
                  .Name("TelerikTree")
                  .ShowCheckBox(true)
                  .BindTo(Model, mappings =>
                  {
                      mappings.For<YourModelTree>
                          (binding => binding
                              .ItemDataBound((item, modelItem) =>
                              {
                                  item.Text = modelItem.Name;
                                  item.Value = modelItem.Id.ToString();
                                  item.Expanded = true;
                                  item.Checked = true;
                              }).Children(c => c.Children));
                  })))

Example of model Tree:

 public class ModelTree
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public IList<ModelTree>() Children {get;set;}
        public ModelTree Parent {get;set;}
    }

Also you can check telerik documentation .If you have any question please ask me.

Upvotes: 1

Related Questions