Question

I have this javascript of code

var store;

function dataBind(servletPath){
   store = Observable(Cache(JsonRest({target:servletPath}), Memory()));
}

The servletPath will return me a json string that looks like this.

[{"colNo":1,"colMemberId":108}]

Lets say I call this javascript function and it returns a record to me. How do I get the "colMemberId" from the store?

Was it helpful?

Solution

If your function returns a Dojo store object then you can access it's contents through the use of it's query() function like so

var store;

function dataBind(servletPath){
    return store = Observable(Cache(Memory({data:[{"colNo":1,"colMemberId":108}]}), Memory()));
}

console.log("store: ", dataBind().query({}));

Calling the query function with an empty object as a parameter will return an array containing the entire contents of the store.

Documentation: http://dojotoolkit.org/reference-guide/1.10/dojo/store/Memory.html

Here is a jsFiddle example : http://jsfiddle.net/kagant15/y7ec4byk/4/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top