Opened 11 years ago

Closed 11 years ago

#8491 closed defect (wontfix)

Tree: unexpected error message when empty items provided

Reported by: Les Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.2.3
Keywords: Tree Cc:
Blocked By: Blocking:

Description (last modified by bill)

The following code fragment results in an error message:

dijit.tree.TreeStoreModel: query null returned 0 items, but must return exactly one item

var data = {identifier: 'id', items: [ ]};
var store = new dojo.data.ItemFileReadStore({data: data});
var model = new dijit.tree.TreeStoreModel({store: store});

new dijit.Tree({model: model});

I'd prefer if no error message (or a better one) was displayed when tree data has no items.

Change History (3)

comment:1 Changed 11 years ago by bill

Description: modified (diff)

If you prefer no error message then perhaps you should be using ForestStoreModel instead of TreeStoreModel, but anyway I guess the "null" in the error message above is confusing? It seems like you didn't provide any query at all to your TreeStoreModel? That's rather strange. Is it supposed to be a hierarchical data source with only one top level item, so that a plain store.fetch() call will get the one item?

comment:2 in reply to:  1 ; Changed 11 years ago by Les

Using TreeStoreModel? I should be able to create a tree with no nodes when no data is provided (sometimes I get an empty array of items from the server). However, the current Tree code requires that there's exactly one data item to construct the root.

The error message (if it has to be displayed) is too technical. It creates support issues. It should simply state that the tree could not be created because no data was provided.

comment:3 in reply to:  2 Changed 11 years ago by bill

Resolution: wontfix
Status: newclosed

Replying to Les:

Using TreeStoreModel I should be able to create a tree with no nodes when no data is provided (sometimes I get an empty array of items from the server). However, the current Tree code requires that there's exactly one data item to construct the root.

TreeStoreModel is working according to it's spec. As I said, it sounds like you want to use ForestStoreModel and are mistakenly using TreeStoreModel.

The error message (if it has to be displayed) is too technical. It creates support issues. It should simply state that the tree could not be created because no data was provided.

Users should never see this error message; it's for developers. Sorry, I like the current message as it gives the developer more information, telling them that the query was run but it returned no data.

Note: See TracTickets for help on using tickets.