mvc3 treeview使用telerik控件js绑定

来源:互联网 发布:4g十网络手机 编辑:程序博客网 时间:2024/05/16 06:00
<div style="width: 300px;">@(Html.Telerik().TreeView().Name("TreeView").ClientEvents(events => events.OnDataBinding("onDataBinding")))</div><script type="text/javascript">function onDataBinding(e){var treeview = $('#TreeView').data('tTreeView');var jsonObject;if (e.item == treeview.element){jsonObject = [{Text: "Product 1", Expanded: true, Items: [{ Text: "Product 1.1", Expanded: true, Items: [{ Text: "Product 1.1.1", Value: 6 }, { Text: "Product 1.1.2"}] }, { Text: "Abyss product", LoadOnDemand: true, Value: "abyss"}]}, { Text: "Product 2 (unavailable)", Enabled: false }, { Text: "Product 3"}]; treeview.bindTo(jsonObject);} else { jsonObject = [{ Text: "Abyss subproduct", LoadOnDemand: true, Value: "abyss"}]; treeview.dataBind(e.item, jsonObject); } }</script>