SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 296 forks source link

dgrid-tree plugin is not showing the children of an expanded node #1015

Open vijilaks opened 10 years ago

vijilaks commented 10 years ago

When I expand a node in the tree of a grid, the ajax call is made to get the children but does not display children. Not sure, where I'm going wrong. Any help is greatly appreciated. Thanks. Here is the code snippet:

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");

});

A basic grid with JsonRest store

cogentParadigm commented 9 years ago

Prior to 0.4.0, I was having a similar issue but only with secondary children. I was able to fix it by changing this line:

container.style.height = scrollHeight ? scrollHeight + "px" : "auto";

to this:

container.style.minHeight = scrollHeight ? scrollHeight + "px" : "auto";

In 0.4.0, I'm not having the same issue but the tree still doesn't expand correctly. If I open up 2 levels and the close the second one, it's children get hidden but the height they occupied does not collapse.

edhager commented 9 years ago

Hi @vijilaks,

The dgrid tree plugin expects getChildren to return a dojo/store/util/QueryResults object. Take a look at the sample getChildren method in the documentation.