Login Register

ItemFileReadStore - dumb problem

Consider the following simple code:

var mData ={ identifier: 'name', items:
[ {'name': 'strength', 'value': '5 of 5'},
{'name': 'Romberg', 'value': 'negative'},
{'name': 'tandem', 'value': 'unsteady'},
{'name': 'tongue', 'value': 'deviates in midline'},
{'name': 'pronator drift', 'value': 'none'},
{'name': 'biceps, triceps', 'value': '2+'},
{'name': 'knees', 'value': '3+'},
{'name': 'ankles', 'value': '1+'}
]
}

var mFile = "motorold.json";
var eStore = new dojo.data.ItemFileReadStore({url: mFile});
//var eStore = new dojo.data.ItemFileReadStore({data: mData});

If I try to read the file from the url, the eStore variable is empty: the _jsonData field is undefined.

If I switch to the internal data as the eStore is correctly populated and the _jsonData field contains the expected array. The data can then be used to load a DataGrid correctly.

The file "motorold.json" does exist in the same directory as the test Javascript file, and is not in any protected. It contains exactly the data shown above.

What dumb thing might I be doing?

i couldn't find any problem

i couldn't find any problem in code if file name is correct, i can suggest one option
1) check for proper file name or try this
var eStore= new dojo.data.ItemFileReadStore({url: "motorold.json"});

Manjunath M

I think it's an issue of

I think it's an issue of lazy loading. The _jsonData field isn't filled in until you try to fetch from the store when you pass in a URL.

For example:

var mFile = "motorold.json";
var eStore = new dojo.data.ItemFileReadStore({url: mFile});
console.log( eStore._jsonData);
eStore.fetchItemByIdentifier({ identity: 'tandem', onItem: console. log });
console.log( eStore._jsonData );

If you are using it in a grid, make sure you are passing a query to your declaration of your model.

Hope this helps.