TreeView gets populated through ajax and every item has LoadOnDemand = true. Now I need the tree to be fully expanded after binding. Calling expand on the client doesn’t work because I guess expand doesn’t support LoadOnDemand thing.
public ActionResult GetListOfDishes(TreeViewItem node)
{
var nodes = new List<TreeViewItem>();
int dishId; int.TryParse(node.Value, out dishId);
DataContext.GetDishes(dishId).ForEach(dish =>
{
var d = new TreeViewItem
{
Text = dish.Name,
Value = dish.Id.ToString(),
LoadOnDemand = dish.IsGroup,
};
nodes.Add(d);
});
return new JsonResult { Data = nodes };
}
@(Html.Telerik().TreeView()
.Name("DishesTree")
.DataBinding(dataBinding => dataBinding.Ajax().Enabled(true).Select("GetListOfDishes", "Dining"))
.ExpandAll(true)
You would need to use the client-side events (onDataBound) and then