AnsweredAssumed Answered

Dynamically Load Dojo Treeview data from SDE Table

Question asked by KeitherJ on Oct 21, 2014
Latest reply on Oct 31, 2014 by KeitherJ

Friends

 

I have successfully loaded TreeView data in statically with the javascript below.

Now I would like to get it from a table.

 

I am using a query task against the table to return results.

I am taking the results and creating a string equal to the Data string in the JavaScript below.

When I pass the string into  as a variable it does not work.

If I copy in the string in , it works.

 

Would any of you have an actual example of how to do this?

I have tried the jsonRest Store and Memory Store.

 

Thank you.

 

Keith Anderson

 

            function LoadTreeViewEdina() {
                // Create test store, adding getChildren() method needed by ObjectStoreModel
                var store = new Memory({
                    data: [
                        { id: 0, label: "Edina" },
                           { id: 1, label: "Parks", URL: 'http://localhost:6080/arcgis/rest/services/gGov_ED/MapServer/4', XY: '45,-93', HoverFeatureNameField: 'PARK_NAME', HoverAddressNameField: 'ADDRESS', parent: 0 },
                           { id: 2, label: "Lakes", URL: 'http://localhost:6080/arcgis/rest/services/gGov_ED/MapServer/3', XY: '55,-83', parent: 0 },
                           { id: 3, label: "Parcels", URL: 'http://localhost:6080/arcgis/rest/services/gGov_ED/MapServer/1', XY: '55,-83', parent: 0 },
                           { id: 4, label: "Addresses", URL: 'http://localhost:6080/arcgis/rest/services/gGov_ED/MapServer/0', XY: '55,-83', parent: 0 },
                           { id: 5, label: "Zoning", URL: 'http://localhost:6080/arcgis/rest/services/gGov_ED/MapServer/2', XY: '55,-83', parent: 0 },
                    ],
                    getChildren: function (object) {
                        return this.query({ parent: object.id });
                    }
                });
                // Create the model
                var model = new ObjectStoreModel({
                    store: store,
                    query: { id: 0 },
                    labelAttr: "label"
                });
                // Custom TreeNode class (based on dijit.TreeNode) that allows rich text labels
                var MyTreeNode = declare(Tree._TreeNode, {
                    _setLabelAttr: { node: "labelNode", type: "innerHTML" }
                });
                // Create the Tree.
                var tree = new Tree({
                    model: model,
                    onClick: LoadFeatureClassFromTreeView,
                    openOnClick: false,
                    _createTreeNode: function (args) {
                        return new MyTreeNode(args);
                    }
                });
                tree.placeAt(dom.byId("treeview"));
                tree.onClick = function (item) {
                    /* load the url from datastore */
                    alert("item = " + item.label);
                    //location.href = item.url;
                };
                tree.startup();
            }

Outcomes