【问题标题】:dgrid Tree rendering flat at firstdgrid 树首先渲染平坦
【发布时间】:2016-11-11 22:41:27
【问题描述】:

我有一个与this 帖子非常相似的问题。

我的症状是一样的(父母和孩子一开始都是平的。你可以“展开”父母让一些孩子在他们下面正常显示,然后你可以再次折叠他们让树显示它应该如何)但提供的解决方案(将 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!"],
		function(/*DOJO:*/declare, lang, dom, domConstruct, template,
				 /*DIJIT*/_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, TitlePane,ContentPane,
				 /*DGRID*/OnDemandGrid, Keyboard, Selection, DigitRegistry, Editor, Tree,
				 /*DSTORE*/Memory, Trackable, TreeStoreMixin){
			return declare("company.widgets.DefaultsWidget", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
				
				//The template defined with dojo.text
				templateString: template,				
				grid: null,
				
				postCreate: function(){
					
					var testData = [];
					var column;
					var i;
					var item;

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

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

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

这是网格与 collection: store 一起显示的方式,

如果您需要更多信息,或者我错过了任何 SO 准则或礼仪,请告诉我,我很乐意进行编辑、改写等。

【问题讨论】:

    标签: tree dojo dgrid dstore


    【解决方案1】:

    似乎导致网格以这种方式显示的问题是根行中没有parent: null。实验室中显示的代码似乎无法按原样工作,并且需要我刚才提到的修复以及我引用的问题中的.getRootCollection() 修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 2013-01-23
      • 2019-03-31
      • 1970-01-01
      • 2013-09-04
      相关资源
      最近更新 更多