Login Register

dojo 1.0.2: dojo.data.ItemFileReadStore not accepting data keyword in constructor?

I am testing out an upgrade to dojo 1.0.2 and I ran into a problem using loaded JSON data to instantiate an item store. I found a thread online that shows the same problem but no answer:

http://www.nabble.com/data-store-td14248070.html

The code example given apparently worked for one person but, like myself, not for the person using 1.0.2:

dojo.require('dojo.data.ItemFileReadStore');
var data = {data: {
    identifier : 'id',
    items : [
      { id : 'a', label: "Letter A" },
      { id : 'b', label: "Letter B" },
      { id : 'c', label: "Letter C" },
      { id : 'd', label: "Letter D" }
    ]
  }};

var myNewStore=new dojo.data.ItemFileReadStore(data);

I made a similar example which also fails:

var imgCtx = {data: {identifier:'item_id', items:[{item_id:1,title:'title',caption:'cap',alt_text:'alt',credits:'cred',height:'100',width:'200'}]}};
    var db = new dojo.data.ItemFileReadStore(imgCtx);

The current online Dojo documentation indicates that the "data" constructor keyword is supported...why then is an empty item store returned from the above code? Is this page accurate:

ItemFileReadeStore Doc Page

??

If it's of any use, here are

If it's of any use, here are my environment characteristics:

Firefox 2.0.0.11
Mac OS 10.4.11
Dojo 1.0.2

Seems to work OK here. The

Seems to work OK here. The thing I occasionally forget is lazy loading. Your item store above, variable db, will indicate an empty store.

But, when you do a fetch() or attach it to a dijit that uses it as a store (which will do its own fetch behind the scenes) you get a populated store.

Just because a store is "defined", doesn't mean you want to populate it at that point.

Hope this helps.