Thursday, 2 June 2011

Sort the fetch search results of Dojo's ItemAndOrReadStore

The JavaScript/Dojo sample below shows how to sort the search results of AndOrReadStore by a specific field (service_name in our example) within the loaded JSON file. Take care that sorting is case sensitive. In a more advanced version, in which I automated the generation of the JSON file, I included a special sort key which is simply the transformation of the service_name to upper case.

var itemAndORStore = new dojox.data.AndOrReadStore( { url : 'serviceWorks/json/services.js' });
itemAndORStore.fetch( { queryOptions : { ignoreCase : true }, query:{complexQuery : finalQuery}, onComplete : onComplete_3, onError : onError, sort: [{attribute: "service_name"}] });

No comments:

Post a Comment