Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Laboratory Sample Code doesn't Produce a Tree #1335

Closed
ghost opened this issue Dec 23, 2016 · 3 comments · Fixed by #1463
Closed

The Laboratory Sample Code doesn't Produce a Tree #1335

ghost opened this issue Dec 23, 2016 · 3 comments · Fixed by #1463

Comments

@ghost
Copy link

ghost commented Dec 23, 2016

The code sample mentioned in the laboratory when Grid, OnDemandGrid, and Tree are selected, doesn't result in a tree structure.

Source: http://dgrid.io/js/dgrid/demos/laboratory/

require([
	'dojo/_base/declare',
	'dstore/Memory',
	'dstore/Trackable',
	'dstore/Tree',
	'dgrid/OnDemandGrid',
	'dgrid/Tree'
], function (declare, Memory, Trackable, TreeStoreMixin, OnDemandGrid, Tree) {
	var store = new (declare([Memory, Trackable, TreeStoreMixin]))({
		data: createData()
	});

	// Instantiate grid
	var grid = new (declare([OnDemandGrid, Tree]))({
		collection: store,
		columns: {
			First_Name: {
				label: 'First Name',
				renderExpando: true
			},
			Last_Name: {
				label: 'Last Name'
			}
		}
	}, 'grid');

	grid.startup();

	function createData() {
		var data = [];
		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;
			}
			data.push(item);
		}

		return data;
	}
});
@ghost ghost changed the title The Laboratory Code doesn't Produce a Tree The Laboratory Sample Code doesn't Produce a Tree Dec 23, 2016
@gprosch
Copy link

gprosch commented Jul 18, 2017

Any update on this? Also, what/where is TreeStoreMixin?

@ghost
Copy link
Author

ghost commented Jul 18, 2017

TreeStoreMixin maps to 'dstore/Tree'.

We got this working by using .getRootCollection() on our store. Source: https://github.com/adpatter/dojo-widget-examples/blob/master/KeyRequestApp.js

`var ReportingEmployeeTreeGrid = declare([ dgridOnDemandGrid, dgridTree, dgridDijitRegistry, dgridColumnResizer ]);

var ReportingEmployeeTreeGridStore = declare([ dstoreMemory, dstoreTrackable, dstoreTree ]);

var tree = new ReportingEmployeeTreeGrid(
{
id : this.id + "_employeeTree",
title : "Request Keys",
selected : true,
region : "center",
keepScrollPosition : true,
collection : this.get("reportingEmployeeTreeGridStore").getRootCollection(),
columns : [
{
field : "name",
label : "Name",
renderExpando : true
},
{
field : "title",
label : "Title"
},
{
field : "roomAccess",
label : "Room Access",
renderCell : lang.hitch(this, this.renderRoomAccessCell)
} ]
});`

@gprosch
Copy link

gprosch commented Jul 18, 2017

Thank you very much for the clarification Adam. I found a similar issue answered on Stack Overflow: https://stackoverflow.com/questions/40557343/dgrid-tree-rendering-flat-at-first

I was just confused about what TreeStoreMixin was and several people seemed to be complaining about the lab code generation which has still not been addressed apparently.

msssk added a commit that referenced this issue May 13, 2020
Laboratory
* fix tree usage and generated code
* update formatter for dgrid 1.3.0
* remove unused code

Tree: improve documentation about dstore/Tree and data format

Fixes #1335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant