kendo-ui - KendoUI : How to insert TreeView inside the TabStrip at run time

标签 kendo-ui kendo-treeview

我需要在 tabstrip 中添加一个 Treeview 。我的情况是,单击按钮后,我会得到一些如下所示的数据。我需要为每个报告生成 1 个选项卡,并在 treeview 中为 Data 放置一个 tab 。这可能吗?如果是的话,你能告诉我如何做到这一点吗?我非常感谢您的帮助。

JSON 数据:

[ 
  Report 1: {  Data: [   ] }, 
  Report 2: {  Data: [  ] } 
]

谢谢你。

最佳答案

我将提议对您的 JSON 进行一些转换,使其看起来像这样:

[
    { Id : "Report 1", Data: [ ] }, 
    { Id : "Report 2", Data: [ ] } 
]

其中 Id 是我们想要为选项卡显示标签的文本, Datatree 的内容。

开始向每个选项卡添加初始(空)内容。
$.each(data, function(idx, elem) {
    elem.Content = "<div>hello</div>";
});

所以你可以这样做:
// Create TabStrip
var ts = $("#tabstrip").kendoTabStrip({
    dataTextField: "Id",
    dataContentField: "Content",
    dataSource: data
}).data("kendoTabStrip");

现在为每个选项卡创建树:
$.each(data, function(idx, item) {
    var c = ts.contentElement(idx);
    $(c).kendoTreeView({
        dataSource : item.Data
    });
});

你可以看到它在这里运行:http://jsfiddle.net/OnaBai/x6Acn/1/

关于kendo-ui - KendoUI : How to insert TreeView inside the TabStrip at run time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21298984/

相关文章:

javascript - 如何在不折叠的情况下禁用所有 Kendo TreeView 节点

asp.net-mvc - Kendo UI Treeview 绑定(bind)

javascript - Kendo treeview expandPath 方法

javascript - 图表上的数据事件绑定(bind)

asp.net - 如何有条件地格式化 Kendo UI 网格单元格(取决于值) Razor

javascript - Kendo UI 组合框获得焦点

angularjs-directive - AngularJS 指令中的父/子点击关系

kendo-ui - Kendo 图表值轴将在点击事件时更改

kendo-ui - 剑道网格 : get all data from row with checked radio button

kendo-ui - 如何将参数传递给剑道网格列模板中的 javascript?