Opened 15 years ago
Closed 15 years ago
#4677 closed defect (invalid)
Dojo.data.itemFileReadStore does not take arrays of objects
Reported by: | guest | Owned by: | Jared Jurkiewicz |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Data | Version: | 0.9 |
Keywords: | Cc: | [email protected]… | |
Blocked By: | Blocking: |
Description
given this data format (which conforms)
items: [
{
select: 'available', options:[
{ value: 'Moe', displayValue: 'Moe'}, { value: 'Larry', displayValue: 'Larry'}, { value: 'Curly', displayValue: 'Curley'}
]
}, {
select: 'selected', options:[
{ value: 'MoeSelected?', displayValue: 'MoeSelected?'}, { value: 'Larry', displayValue: 'Larry'}, { value: 'Curly', displayValue: 'Curley'}
]
}
]
the onComplete method is never called. If I take out the option objects, and replace that with a simple array of strings or numbers, the onComplete of fetch:
this.dataStore.fetch({
scope:this,
onComplete: this.populateOptions
});
is called. I looked in ItemFileReadStore?.js line 416, it doesnt seem to be fielding nested objects in arrays, just values.
Please email [email protected]…
Change History (4)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Cc: | [email protected]… added |
---|
comment:3 Changed 15 years ago by
Support of arrays of items does work. There are examples of it in tests/data/geography_hierarchy_small.json
So, it doesn't like something about the data you passed in. I'm guessing you didn't provide an onError handler so whatever failed was eaten.
comment:4 Changed 15 years ago by
Component: | DojoX Data → Data |
---|---|
Resolution: | → invalid |
Status: | new → closed |
In fact, you may have a problem with your handlers and how you're providing them, because this works for me (Including your dataset). See:
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test of ItemFileReadStore?</title> <style type="text/css">
@import "dijit/themes/tundra/tundra.css"; @import "dojo/dojo.css"
</style> <script type="text/javascript" src="dojo/dojo.js"
djConfig="parseOnLoad: false, isDebug: true"></script>
<script type="text/javascript">
dojo.require("dojo.data.ItemFileReadStore?");
function init() {
var data = {
items: [
{
select: 'available', options:[
{ value: 'Moe', displayValue: 'Moe'}, { value: 'Larry', displayValue: 'Larry'}, { value: 'Curly', displayValue: 'Curley'}
]
}, {
select: 'selected', options:[
{ value: 'MoeSelected??', displayValue: 'MoeSelected??'}, { value: 'Larry', displayValue: 'Larry'}, { value: 'Curly', displayValue: 'Curley'}
]
}
]
};
var store = new dojo.data.ItemFileReadStore?({data: data}); var request = {
scope:this, onComplete: function(items, request){console.log("onComplete called with items: " + items.length);
for (var i = 0; i < items.length; i++) {
console.log("Found item with display value: " + store.getValue(items[i], "displayValue"));
}
},
onError: function(error, request){console.debug(error)}, queryOptions: {deep:true}
} store.fetch(request);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra"> </body> </html>
Console log output: onComplete called with items: 8 Found item with display value: undefined Found item with display value: Moe Found item with display value: Larry Found item with display value: Curley Found item with display value: undefined Found item with display value: MoeSelected?? Found item with display value: Larry Found item with display value: Curley
Check how your handlers are being passed/associated. I imagine you are not properly hitching them or the like. If you still believe this is an issue, then please provide a complete testcase which shows the issue, as the data provided works fine in my testcase.
Marking invalid, as it appears it is probably a user function error, not an ItemFileReadStore? error.
As always, patches are welcome. I have little time currently to field anything dojo.data related.