dgrid 0.4.0树在用户交互之前看起来平坦 [英] dgrid 0.4.0 tree looks flat before user interacts

查看:197
本文介绍了dgrid 0.4.0树在用户交互之前看起来平坦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用dgrid 0.4.0显示树结构。 (没有以前的版本0.3.x的经验)。

Trying to use dgrid 0.4.0 to display a tree structure. (no prior experience with previous versions 0.3.x).

我用两个文件夹构建了此示例:alice和bob;每个都有几个文件(叶)。

I built this sample with two folders : alice and bob ; each would have a few files (leaves) in it.

商店(astore.js)

The store ("astore.js")

define(['dojo/_base/declare',
       './dstore/Memory',
       './dstore/Tree'],

       function(declare, Memory, Tree) {
           var store = new (declare([Memory, Tree], {}))();

           store.add({node:'bob',     id:1, parent:null, hasChildren:true});
           store.add({node:'alice',   id:2, parent:null, hasChildren:true});

           store.add({node:'thesis',  id:3, parent:1,    hasChildren:false});
           store.add({node:'game',    id:4, parent:1,    hasChildren:false});
           store.add({node:'picture', id:5, parent:2,    hasChildren:false});
           store.add({node:'plan',    id:6, parent:2,    hasChildren:false});
           store.add({node:'mail',    id:7, parent:2,    hasChildren:false});

           return store;
       });

启动脚本:

require(['dojo/_base/declare',
        'app/dgrid/OnDemandGrid',
        'app/dgrid/Tree',
        'app/astore'], 
        function (declare, OnDemandGrid, Tree, astore) {

            w = new (declare([OnDemandGrid, Tree],{}))({
                collection: astore,
                columns:[
                    {field:'node', label:'Whatever...', renderExpando:true}
                ]
            }, 'slot');

            w.startup();
        });

显示小部件时,数据总是看起来平坦:

The data always looks flat when the widget is displayed :

点击bob后,该部分被整理出来:

After I click on "bob", that part gets sorted out :

然后点击alice,最后一切都看起来不错:

Then I click on "alice", and all looks fine at last :

然而如果我对列进行排序,我会再次混淆整个东西,比以往更糟糕:

However if I sort on a column, I mess the whole stuff up again, worse than ever :

我已经尝试了实验室的示例代码,并获得相同的结果。我的dgrid组件通过Bower下载。这个问题出现在两台不同的计算机上,不同的操作系统和浏览器。而且我的想法是干涸的:S任何投入都非常感谢!

I've experimented with the sample code from the laboratory, and get the same results. My dgrid components were downloaded via Bower. This issue is present on two different computers, with different OSs and browers. And I'm running dry on ideas... :S Any input extremely appreciated !

推荐答案

正如Dylan和我自己所说相同问题的 github问题,您只需将集合传递到网格即可代表顶级项目。当您使用 dstore / Tree 时,您可以为此目的调用 store.getRootCollection()

As noted by Dylan and myself on the github issue with the same question, you need to pass a collection to your grid that only represents the top-level items. When using dstore/Tree, you can call store.getRootCollection() for this purpose.

所以,而不是 collection:astore ,你需要 collection:astore.getRootCollection()

So instead of collection: astore, you want collection: astore.getRootCollection().

这篇关于dgrid 0.4.0树在用户交互之前看起来平坦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆