Telerik MVC TreeView。 Ajax绑定后如何扩展所有节点?

| 通过ajax填充TreeView,每个项目都有has0ѭ。现在,我需要在绑定后将树完全展开。在客户端上调用
expand
不起作用,因为我猜
expand
不支持LoadOnDemand。
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)
    
已邀请:
        您将需要使用客户端事件(onDataBound),然后
<script type=\"text/javascript\">
    function expandTree(e) {
        var treeview = $(\"#DishesTree\").data(\"tTreeView\");
        treeview.expand();
    }
</script>

<% Html.Telerik().TreeView()
        .Name(\"DishesTree\")
        .DataBinding(dataBinding => dataBinding.Ajax().Enabled(true).Select(\"GetListOfDishes\", \"Dining\"))
        .ClientEvents(c => c.OnDataBound(\"expandTree\")) %>
    

要回复问题请先登录注册