2016-11-11 61 views
0

我有一个非常类似的问题this岗位。dgrid树渲染持平于第一

我的症状是一样的(首先让父母和孩子平躺,你可以“扩大”父母,让孩子在他们的正下方显示,然后你可以再次折叠他们以得到树显示它应该如何),但提供的解决方案(通过store.getRootCollection()到电网,而不是仅仅店),对我来说不起作用。如果我这样做,我什么也没得到,但显示的标题。首先,我试图使用dgrid laboratory中显示的代码(只需在“网格要素”中选中“树”)来使其工作,以尽可能消除我的错误。

唯一的东西我能想到这是从我的例子代码不同的是,我正在做一个自定义部件的这里面的网格,并且我加载其他几个模块(我知道我需要他们后来)

define(["dojo/_base/declare", 
 
     "dojo/_base/lang", 
 
     "dojo/dom", 
 
     "dojo/dom-construct", 
 
     "dojo/text!./templates/DefaultsWidget.html", 
 
     "dijit/_WidgetBase", 
 
     "dijit/_TemplatedMixin", 
 
     "dijit/_WidgetsInTemplateMixin", 
 
     "dijit/TitlePane", 
 
     "dijit/layout/ContentPane", 
 
     "dgrid/OnDemandGrid", 
 
     "dgrid/Keyboard", 
 
     "dgrid/Selection", 
 
     "dgrid/extensions/DijitRegistry", 
 
     "dgrid/Editor", 
 
     "dgrid/Tree", 
 
     "dstore/Memory", 
 
     "dstore/Trackable", 
 
     "dstore/Tree", 
 
     "dojo/domReady!"], 
 
\t \t function(/*DOJO:*/declare, lang, dom, domConstruct, template, 
 
\t \t \t \t /*DIJIT*/_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, TitlePane,ContentPane, 
 
\t \t \t \t /*DGRID*/OnDemandGrid, Keyboard, Selection, DigitRegistry, Editor, Tree, 
 
\t \t \t \t /*DSTORE*/Memory, Trackable, TreeStoreMixin){ 
 
\t \t \t return declare("company.widgets.DefaultsWidget", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { 
 
\t \t \t \t 
 
\t \t \t \t //The template defined with dojo.text 
 
\t \t \t \t templateString: template, \t \t \t \t 
 
\t \t \t \t grid: null, 
 
\t \t \t \t 
 
\t \t \t \t postCreate: function(){ 
 
\t \t \t \t \t 
 
\t \t \t \t \t var testData = []; 
 
\t \t \t \t \t var column; 
 
\t \t \t \t \t var i; 
 
\t \t \t \t \t var item; 
 

 
\t \t \t \t \t for (i = 0; i < 50; i++) { 
 
\t \t \t \t \t \t item = {}; 
 
\t \t \t \t \t \t for (column in { First_Name: 1, Last_Name: 1 }) { 
 
\t \t \t \t \t \t \t item.id = i; 
 
\t \t \t \t \t \t \t item[column] = column + '_' + (i + 1); 
 
\t \t \t \t \t \t } 
 
\t \t \t \t \t \t if (i > 1) { 
 
\t \t \t \t \t \t \t item.hasChildren = false; 
 
\t \t \t \t \t \t \t item.parent = i % 2; 
 
\t \t \t \t \t \t } 
 
\t \t \t \t \t \t testData.push(item); 
 
\t \t \t \t \t } 
 
\t \t \t \t \t 
 
\t \t \t \t \t var store = new (declare([Memory, Trackable, TreeStoreMixin]))({ 
 
\t \t \t \t \t \t data: testData 
 
\t \t \t \t \t }); 
 
\t \t \t \t \t 
 
\t \t \t \t \t // Instantiate grid 
 
\t \t \t \t \t this.grid = new (declare([OnDemandGrid, Tree]))({ 
 
\t \t \t \t \t \t collection: store, 
 
\t \t \t \t \t \t columns: { 
 
\t \t \t \t \t \t \t First_Name: { 
 
\t \t \t \t \t \t \t \t label: 'First Name', 
 
\t \t \t \t \t \t \t \t renderExpando: true 
 
\t \t \t \t \t \t \t }, 
 
\t \t \t \t \t \t \t Last_Name: { 
 
\t \t \t \t \t \t \t \t label: 'Last Name' 
 
\t \t \t \t \t \t \t } 
 
\t \t \t \t \t \t }, 
 
\t \t \t \t \t }, this.testGrid); 
 
\t \t \t \t \t 
 

 
\t \t \t \t }, 
 
\t \t \t \t startup: function() { 
 
\t \t \t \t \t this.grid.startup(); 
 
\t \t \t \t } 
 

 
\t \t \t }); //return declare 
 
     }//function 
 
);//define

这是怎么网格显示集合:商店,

enter image description here

请让我知道如果你需要更多的信息,或者如果我错过了任何SO指导方针或礼节,我会很乐意编辑,改写等。

回答

0

看来,导致网格显示此问题方法是根行并没有在他们parent: null。在实验室中显示的代码不会出现过去一样工作,并要求这两个我刚才提到的修复,以及从我所引用的问题.getRootCollection()修复。