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

[Solved] Show the last level CheckNode

1 Answer 38 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sam
Top achievements
Rank 1
sam asked on 17 Dec 2010, 03:05 AM
My treeview has two level and three level , but i only want to show the checkbox in the last level , anyone can help me?

<% IQueryable<TreeViewItem> checkedNodes = ListHelper.GetProductCategories(Model.Product.ProductID); %>
       <%Html.Telerik().TreeView()           
         .Name("TreeView")
         .ShowCheckBox(true)
         .BindTo(productRepository.GetCategories(null),mappings =>           
           {
            mappings.For<ProductCategoryList>(binding => binding
             .ItemDataBound((item, category) =>
             {
              item.Text = category.CategoryName;
              item.Value = category.CategoryID.ToString();
              if (checkedNodes != null)
              {
               item.Checked = checkedNodes
                .Where(e => e.Value.Equals(category.CategoryID.ToString()))
                .FirstOrDefault() != null;
              }
             })
             .Children(category => category.Children));
            mappings.For<ProductCategoryList>(binding => binding
              .ItemDataBound((item, children) =>
              {
               item.Text = children.CategoryName;
               item.Value = children.CategoryID.ToString();
               if (checkedNodes != null)
               {
                item.Checked = checkedNodes
                 .Where(e => e.Value.Equals(children.CategoryID.ToString()))
                 .FirstOrDefault() != null;
                item.Expanded = true;
               }
              }));
           })
           .Render();
      %>

these are my code of treeview , waiting for answer online , it will be helpfull if has any example. Thanks

1 Answer, 1 is accepted

Sort by
0
sam
Top achievements
Rank 1
answered on 17 Dec 2010, 06:14 AM
i fixed by myself, share the code to help others

<script type="text/javascript">
$(function () {
   var allCheckboxes = $('#TreeView').find("li:has(ul)").find('> div > .t-checkbox :checkbox');
   $.each(allCheckboxes, function () {
    $(this).hide();
   });
  });
</script>
Tags
TreeView
Asked by
sam
Top achievements
Rank 1
Answers by
sam
Top achievements
Rank 1
Share this question
or