0
votes

I want to populate the Kendo TreeView in which 2 nodes are local dataSource and the last node should be remote Datasource

Here is my code:

$("#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,
                                                            }
                                                        },
                                                    }
                                                }
                                            }
                                        }

                                    }
                                }
                            }
                        });

Using above code I am getting structure as below Where Initiate and Analyze are Local DataSource and Monto Carlo is Remote DataSource but I don't want the node again to be Monto Carlo under it that should be the direct remote DataSource from Database

enter image description here so help me in this to solve

Thanks in Advance!!!

1

1 Answers

0
votes

you can change your read property to a function:

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

You can see a example in here. The idea is to use options.success(result); the result is the merged dataSource (remote and local).