I have a spring mvc based app that returns me a list of products which I wish to render in a dojo datagrid.I have used a org.springframework.web.servlet.view.ContentNegotiatingViewResolver that uses MappingJackson2JsonView as the default view.
Here is my spring view configuration
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
</bean>
</list>
</property>
</bean>
this is my basic dojo script
<script>
require([
"dojo/store/JsonRest",
"dojo/store/Memory",
"dojo/store/Cache",
"dojox/grid/DataGrid",
"dojo/data/ObjectStore",
/*"dojo/query",*/
"dojo/domReady!"
], function(JsonRest, Memory, Cache, DataGrid, ObjectStore, query){
var myStore, dataStore, grid;
myStore = Cache(JsonRest({target:"products.do"}), Memory());
alert("MyStore : "+JSON.stringify(myStore));
grid = new DataGrid({
store: dataStore = new ObjectStore({objectStore: myStore}),
structure: [
{name:"Id", field:"id", width: "200px"},
{name:"Description", field:"description", width: "200px", editable: true},
{name:"Price", field:"price", width: "200px"},
{name:"Category", field:"category", width: "200px", editable: true}
]
}, "gridDiv"); // make sure you have a target HTML element with this id
grid.startup();
alert("DataStore : "+JSON.stringify(dataStore));
});
</script>
There is no javascript error however all that i see is a empty grid. On checking with Firebug I see this in the response
So my serverside to front end hookup seems to be correct.What is not clear to me is despite this the grid doesn't reflect any rows.Why could this be happening?What am I missing or doing wrong?Do let me know if any other relevant bit of information is required