Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#4977 closed defect (fixed)

As requested: Trees not working with ItemFileWriteStore

Reported by: guest Owned by:
Priority: high Milestone:
Component: Dijit Version: 1.0
Keywords: Tree, ItemFileWriteStore Cc:
Blocked By: Blocking:


Have encountered problems with both the 0.9 and 1.0 (beta) versions of Trees, when used with an ItemFileWriteStore? that I'm using as a persistent store for the data I'm working with.

In 0.9, the item hierarchy was displayed incorrectly, when the json store used _references, i.e when the save flattens the data structure. Got it more or less working by writing my own save that didn't flatten.

Posted these results to the forum, where I was advised to try the 1.0 beta, which I did.

In 1.0, the item hierarchy is not displayed at all, and the custom save I wrote didn't work anymore, either.

So, I was asked to submit a new ticket for this problem. Here it is.

In particular, I have a test case that produces a three-level hierarchy: package contains items which contain sub items. All of these show up at the outer level, regardless of the query I use in the tree initialization code.

I have a test case, in the form of a NetBeans? project, that displays this. Hopefully, I'll get to upload this at some point in this process...

The project does not include the dojo toolkit directory, since that adds many MBs to the size of the file. You will need to put the toolkit in the build/web directory to just run or the web directory to build.

I've already created an item hierarchy by running the web app, or you can create your own by clicking on the new package button in the tool bar.

Attachments (2) (29.2 KB) - added by guest 14 years ago.
Zip file of NetBeans? project
badTree.html (2.6 KB) - added by guest 14 years ago.
Another example of the misbehaving tree - taken from documentation.

Download all attachments as: .zip

Change History (7)

Changed 14 years ago by guest

Attachment: added

Zip file of NetBeans? project

comment:1 Changed 14 years ago by Adam Peller

Component: CoreData
Owner: changed from anonymous to Jared Jurkiewicz

comment:2 Changed 14 years ago by Adam Peller

Component: DataDijit
Owner: Jared Jurkiewicz deleted

oops, sorry. this is the tree bug.

Changed 14 years ago by guest

Attachment: badTree.html added

Another example of the misbehaving tree - taken from documentation.

comment:3 Changed 14 years ago by bill

Hi there. Sorry you are having these problems. I looked at badTree.html listed above but that seems like a bad test case because no query is specified at all, so it's natural for all the items to show up. In your test case I see in script.js you have a query:

	var tree = new dijit.Tree({id: "testTree", 
			    store: mainStore,
			    childrenAttr: "children",
			    labelAttr: "name",
			    query: "{type:'package'}"

However, mainStore is empty when you create the tree and then you add all the items to it, right? The problem is that when a new item is added to the data store Tree has no way of knowing if that item matches the query or not, without rerunning the whole query. So I think in 1.0 it just assumed it matched the query.

If that's the case then this is a dup of #5536. The best we can do in that case is to provide hooks for the developer to process new top level items being added to the tree, as was checked in (see that bug).

comment:4 Changed 14 years ago by bill

Resolution: fixed
Status: newclosed

(In [12309]) - Fix DnD for Tree, specifically when dragging elements within the Tree

  • Refactor Tree to take a single item as the root node, rather than a set of items specified by a query. The root node of the tree can be hidden via the showRoot parameter. Query and label parameters deprecated; will be removed in v2.
  • implemented ForestStoreDecorator? which wraps a given store, mapping all items matching a given query as children of a synthesized root item. Use this to connect Tree to stores that don't have a single root item.

Reason for changes: The old tree design worked for simple cases but broke down for DnD. Refactoring let's users define handlers for when a node is added/removed from the top of the tree (ie, when it changes between a top level item and a child of another item, or vice-versa), and for efficiently detecting changes to the list/order of top level items (and then notifying Tree).

Note that Tree DnD won't work with ItemFileWriteStore? and nested data (rather than _reference). See #5786 about that.

Fixes #4544, #4977, #5560, refs #5536


comment:5 Changed 14 years ago by bill

(In [12417]) Update Tree tests to explicitly instantiate ForestStoreDecorator?. Refs #4544, #4977, #5560, #5536.

Note: See TracTickets for help on using tickets.