Hi. For the life of me, I can't figure out how to programmatically check checkboxes on a treeview loaded with hiearchical data.
I've even tried setting the CheckedItems = StoreageItems, using your example. I must be missing some magic sauce. The treeview comes up just fine. I just can't precheck items.
Help!!!!
<TelerikTreeView Data="@tvData" CheckBoxMode="TreeViewCheckBoxMode.Multiple"@bind-CheckedItems="@CheckedItems" CheckParents="true" CheckChildren="true" OnExpand="@OnExpand"> <TreeViewBindings> <TreeViewBinding IdField="CategoryId" ParentIdField="ParentItemId" ItemsField="Items" HasChildrenField="HasChildren" TextField="CategoryName" IconField="Icon"> </TreeViewBinding> <TreeViewBinding Level="1" TextField="CategoryName" /> </TreeViewBindings> </TelerikTreeView> public IEnumerable<object> CheckedItems { get; set; } public TreeViewCheckBoxMode CheckBoxMode { get; set; } = TreeViewCheckBoxMode.Multiple;public void LoadtvRootData() { List<CategoryItem> lst = new List<CategoryItem>(); // data requested and received for a certain node var q = from a in db.Categories where a.IsActive == true && a.SubscriberId == appData.AppUser.Id && a.ParentCategoryId == null orderby a.CategoryName select a; var lst1 = q.ToList(); foreach(var item in lst1) { CategoryItem ci = new CategoryItem(item); var q1 = from a in db.Categories where a.ParentCategoryId == item.Id select new CategoryItem(a) { Category = a, HasChildren = ATDBContext.udfCategoryHasChildren(a.Id), }; ci.Items = q1.ToList(); ci.HasChildren = ci.Items.Count > 0; ci.Category = item; lst.Add(ci); } tvData = new List<CategoryItem>(lst); CheckedItems = tvData;}