带有树插件的dgrid在展开时不显示子项

时间:2014-10-07 20:40:08

标签: dgrid

当我在网格树中展开节点时,会调用ajax来获取子节点但不显示子节点。当然,在客户端出现问题,我不确定,我在哪里丢失。 任何帮助是极大的赞赏。谢谢。

以下是代码段:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Test JsonRest store</title>
    <meta name="viewport" content="width=570">
    <style>
        @import "static/dojo-release-1.9.0/dojo/resources/dojo.css";    
        @import "static/dojo-release-1.9.0/dgrid/css/skins/claro.css";
        @import "static/dojo-release-1.9.0/dijit/themes/tundra/tundra.css";
        @import "static/dojo-release-1.9.0/dgrid/css/skins/tundra.css";

        h2 {
            margin: 12px;
        }
        .heading {
            font-weight: bold;
            padding-bottom: 0.25em;
        }
        .dgrid {
            margin: 10px;
        }


    </style>
    <script type="text/javascript" data-dojo-config="'async':true,'parseOnLoad':true" src="static/dojo-release-1.9.0/dojo/dojo.js"></script>
    <script>        
        require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/editor", 
       "dgrid/Keyboard", "dgrid/Selection", "dgrid/tree", "dgrid/extensions/DnD",
       "dojo/_base/declare", "dojo/store/JsonRest", "dojox/json/ref", "dojo/store/Observable",
       "dojo/store/Cache", "dojo/store/Memory", "dojo/domReady!"], function(List, Grid, Selection, editor, Keyboard, Selection, tree, DnD, declare, JsonRest, jsonRef, Observable, Cache, Memory){

            var DnDList = declare([List, Keyboard, Selection, DnD]),
            DnDGrid = declare([Grid, Keyboard, Selection, DnD]);

            //dojox.json.ref.refAttribute = "uuid";
            var rootUuid = "ee9ac5d2-a07c-3981-a57a-f7f26baf38d8";

            var testStore = Cache(JsonRest({
            //Observable(Cache(JsonRest({
                target:"/uuid/",
                idProperty: "uuid",
                query: 

                function(query, options){                           
                    query = rootUuid+"/dojoTreeRoot";
                    options="";
                    return JsonRest.prototype.query.call(this, query, options);
                },                      
                getChildren : function(parent, options){                            
                    return testStore.get(parent.uuid).children;
                }               
            }), Memory());                                      

            var columns = [
                tree({label:'Name', field:'displayName', sortable: false})
            ];

            window.grid = new DnDGrid({ //new (declare([Grid, Selection, Keyboard]))({
                //sort: "id",
                store: testStore,
                selectionMode: "single",
                loadingMessage: "Loading data...",
                //noDataMessage: "No results found.",
                getBeforePut: false,
                columns: columns,                       
                dndParams: {
                    allowNested: true, // also pick up indirect children w/ dojoDndItem class
                    checkAcceptance: function(source, nodes) {
                        return source !== this; // Don't self-accept.
                    }
                }                   
            }, "grid");
    });
</script>
</head>
<body class="claro">
    <h2>A basic grid with JsonRest store</h2>
    <div id="grid"></div>
</body>
</html>

0 个答案:

没有答案
相关问题