Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5876 closed enhancement (wontfix)

QueryReadStore: support _reference

Reported by: bill Owned by: wolfram
Priority: high Milestone: 1.2
Component: DojoX Data Version: 1.0
Keywords: Cc: Jared Jurkiewicz, josh@…
Blocked By: Blocking:

Description (last modified by bill)

See http://www.dojotoolkit.org/comment/reply/5559/12172#comment-12172. In order to use QueryReadStore for dijit.Tree, or any kind of application where one item points to another item, need to support that functionality inside of QueryReadStore.

Presumably the initial GET request for an item returns something like

{ name:'Asia', type:'continent',
         children:[{_reference:'China'},
                          {_reference:'India'},
                          {_reference:'Russia'}, 
                          {_reference:'Mongolia'}] }

and then store.isItem( {_reference:'China'} ) returns true, and store.isItemLoaded({_reference:'China'}) returns false, but then store.loadItem({_reference:'China'}) will convert that into an actual item.

Of course it's pretty inefficient to make a separate GET call for each of the children of Asia. Might be better to get them all at once... It's also inefficient to have to list stubs for each child item to begin with. It would be better to just have a stub for the whole children array, like:

{ name:'Asia', type:'continent',
         children:[ _stub ] }

Unfortunately that's also got issues, given the dojo.data API, since store.getValues(item, "children") is synchronous, and it's bad to make a synchronous call do a GET request.

Change History (11)

comment:1 Changed 12 years ago by bill

Description: modified (diff)

comment:2 Changed 12 years ago by Jared Jurkiewicz

Cc: Jared Jurkiewicz added

comment:3 Changed 12 years ago by Jared Jurkiewicz

Cc: jaredj.jurkiewicz@… added

comment:4 Changed 12 years ago by Jared Jurkiewicz

Cc: jared.jurkiewicz@… added; jaredj.jurkiewicz@… removed

comment:5 Changed 12 years ago by Jared Jurkiewicz

Owner: changed from Jared Jurkiewicz to wolfram

Wolfram,

Assigning this over to you since you generally maintain the QueryReadStore? code.

What Bill is asking for here may be outside the intended scope of this store, and that's fine if you want to not deal with hierarchical items in your store model. But, I wanted your input/opinion on this request.

comment:6 Changed 12 years ago by bill

Yeah, feel free to close as wontfix. I'm thinking (in dijit.Tree) to continue providing an async callback to get the children of an item, and this issue can be handled there rather than in QueryReadStore?.

comment:7 Changed 12 years ago by dylan

Milestone: 1.2

comment:8 Changed 12 years ago by bill

Resolution: wontfix
Status: newclosed

I'm just going to close this; we don't need it for Tree anymore and it doesn't seem like anyone would use this feature. (If other people need it we can reopen the ticket.)

comment:9 Changed 12 years ago by guest

I would like to see this ticket reopened - unless I'm confused. I use a QueryReadStore? (dojo 1.0.2) with a Tree and it seems to work - I had to create a custom store that overrode the fetch() method.

The problem I have with using a FileItemReadStore? is that the full tree is extremely large and a full json representation would take minutes to create, and it's possible that one node in the tree could point back up to a parent node, causing a loop. For me being able to query the server on child node expansion is key because the user likely will take one path through the child nodes, perhaps only expanding a couple child/grandchild nodes. It's a bit hard to explain. Will this be possible with QueryReadStore/Tree? in 1.1?

Please add josh@… to CC list

comment:10 Changed 12 years ago by bill

Cc: josh@… added; jared.jurkiewicz@… removed

Hi Josh, I think you are misunderstanding. You should definitely be able to use QueryReadStore with Tree, but given the TreeStoreModel or ForestStoreModel abstraction (with the getChildren() method), you should be able to achieve it w/out a _reference feature in QueryReadStore. I suspect the data you get from the server will look like either:

 { id: 123, label: "foo", children: [1234, 5454, 24324] }

or perhaps a child will point to it's parent like

 { id: 1234, label: "bar", parent: 1234  }

Either way should be able to write getChildren to look at an item and get all the children for that item. Maybe it will be code like

  this.store.fetch({query: {parentId: arg} });

comment:11 in reply to:  10 Changed 12 years ago by guest

Replying to bill:

Hi Josh, I think you are misunderstanding. You should definitely be able to use QueryReadStore with Tree, but given the TreeStoreModel or ForestStoreModel abstraction (with the getChildren() method), you should be able to achieve it w/out a _reference feature in QueryReadStore. I suspect the data you get from the server will look like either:

 { id: 123, label: "foo", children: [1234, 5454, 24324] }

or perhaps a child will point to it's parent like

 { id: 1234, label: "bar", parent: 1234  }

Either way should be able to write getChildren to look at an item and get all the children for that item. Maybe it will be code like

  this.store.fetch({query: {parentId: arg} });

Thank you for the clarification, I will give it a try in the next Dojo 1.1 beta.

Josh

Note: See TracTickets for help on using tickets.