#5545 closed defect (worksforme)
dojo.data.ItemFileReadStore not accepting data keyword in constructor
Reported by: | guest | Owned by: | Jared Jurkiewicz |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Data | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
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 but either of the above 2 examples return empty item stores. This seems like a bug.
I am using
Firefox 2.0.0.11 Mac OS 10.4.11 Dojo 1.0.2 The above examples were tested using the Firebug Mozilla plugin.
Attachments (1)
Change History (3)
comment:1 Changed 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 Changed 13 years ago by
And the result in the browser from the was the following:
Adding in the values for all items for store named 'db': title 200 100 Adding in the values for all items for store named 'store2': a Letter A b Letter B c Letter C d Letter D
Far as I can tell, it accepts data in the constructor fine. My guess is your problem is in usage somewhere. Since your example doesn't show how you are doing a 'fetch' across the store, I cannot tell you what you have done wrong there.
Changed 13 years ago by
And here's the example code I used. Just DL and drop into the root of a doko build and load it in a browser. It shows the data constructor option working fine. So, my guess is whatever you're doing around the store is incorrect.
The store works fine as far as I can tell, even using your example code (plus the many projects I know of at my company which use it in this manner).
I was able to take your code, unmodified, and fetch over it, getting out your item and its values. The only problem I see with your example is you pass the object in, but you never actually do anything with it. Where is your fetch call to query across it to access the items? Note that the data you pass in isn't even injected into store structures until the first fetch() or fetchByIdentity(), it's lazy-loading, effectively.
Here's what I did: <html> <head>
</head>
<body class="tundra"> </body>