繁体   English   中英

Kendo Treeview的本地和远程数据源

[英]Local and Remote DataSource to Kendo Treeview

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

这是我的代码:

$("#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,它应该是数据库中的直接远程数据源。

在此处输入图片说明 所以帮我解决

提前致谢!!!

您可以将read属性更改为一个函数:

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. */ }

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM