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

查看:29
本文介绍了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.getRootCollection() 而不是 collection: astore.

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

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

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