Ticket #5876 (closed enhancement: wontfix)

Opened 3 months ago

Last modified 2 months ago

QueryReadStore: support _reference

Reported by: bill Owned by: wolfram
Priority: normal Milestone: 1.2
Component: DojoX Data Version: 1.0
Severity: normal Keywords:
Cc: jaredj, josh@…

Description (last modified by bill) (diff)

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

  Changed 3 months ago by bill

  • description modified (diff)

  Changed 3 months ago by jaredj

  • cc jaredj added

  Changed 3 months ago by jaredj

  • cc jaredj.jurkiewicz@… added

  Changed 3 months ago by jaredj

  • cc jared.jurkiewicz@… added; jaredj.jurkiewicz@… removed

  Changed 3 months ago by jaredj

  • owner changed from jaredj 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.

  Changed 3 months 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?.

  Changed 3 months ago by dylan

  • milestone set to 1.2

  Changed 3 months ago by bill

  • status changed from new to closed
  • resolution set to wontfix

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.)

  Changed 2 months 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

follow-up: ↓ 11   Changed 2 months 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} });

in reply to: ↑ 10   Changed 2 months 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.