【问题标题】:Local and Remote DataSource to Kendo Treeview本地和远程数据源到 Kendo Treeview
【发布时间】:2016-08-16 15:26:55
【问题描述】:

我想填充 Kendo TreeView,其中 2 个节点是本地数据源,最后一个节点应该是远程数据源

这是我的代码:

$("#AftermarketTreeView").kendoTreeView({
                            dataTextField: ["text", "text", "MC_ANALYSIS_NAME"],
                            dataSource: {
                                data: [
                                  {
                                      text: "Initiate",
                                      items: [
                                        { text: "Parts Selection", haschildren: false },
                                        { text: "Assumptions", haschildren: false },
                                        { text: "Team", haschildren: false },
                                      ]
                                  },
                                  {
                                      text: "Analyze",
                                      items: [
                                        { text: "Part Attributes", haschildren: false },
                                        { text: "Aftermarket Evaluation", haschildren: false }
                                      ]
                                  },
                                  {
                                      text: "Monto Carlo",
                                      items: [
                                        { text: "Monto Carlo", haschildren: true }

                                      ]
                                  }
                                ],
                                schema: {
                                    model: {
                                        hasChildren: "items",

                                        children: {
                                            schema: {
                                                data: "items",
                                                model: {
                                                    hasChildren: "haschildren",
                                                    children: {
                                                        schema: {
                                                            // override the schema.data setting from the parent
                                                            data: function (response) {
                                                                return response;
                                                            }
                                                        },
                                                        transport: {
                                                            read: {
                                                                url: ResolveUrl("/CreateMaintainAnalysis/GetMontoCarloData/"),
                                                                dataType: "jsonp",
                                                                data:onDataSendAnalysisID,
                                                            }
                                                        },
                                                    }
                                                }
                                            }
                                        }

                                    }
                                }
                            }
                        });

使用上面的代码,我得到如下结构 其中 Initiate 和 Analyze 是本地数据源,Monto Carlo 是远程数据源,但我不希望节点再次成为其下的 Monto Carlo,它应该是来自数据库的直接远程数据源

所以帮我解决这个问题

提前致谢!!!

【问题讨论】:

    标签: javascript kendo-ui kendo-treeview


    【解决方案1】:

    您可以将读取属性更改为函数:

    read: function(options) { /* here you can do the ajax call for the remote dataSource and then you can merge the local dataSource with the remote dataSource, you can create a new array to accomplish this. */ }
    

    您可以在here 中查看示例。 这个想法是使用 options.success(result);结果是合并的数据源(远程和本地)。

    【讨论】:

    • 我试过了,但是因为我是剑道新手..无法理解需要放置的位置和内容
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 2012-10-25
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多