I have a json like
[
{
"switchType": {
"name": "sansayv15",
"perform": false,
"createBy": null,
"createDate": null,
"intId": 1,
"id": 1
},
"collectorType": {
"name": "FTP",
"perform": false,
"createBy": null,
"createDate": null,
"intId": 1,
"id": 1
},
"fileType": {
"name": "TEXT",
"perform": false,
"createBy": null,
"createDate": null,
"intId": 1,
"id": 1
},
"exportType": {
"name": "DB",
"perform": false,
"createBy": null,
"createDate": null,
"intId": 1,
"id": 1
},
"linesToSkip": "1",
"checkValidate": "true",
"checkDuplicate": "true",
"driver": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://localhost:3306/panamaxmediation",
"tableName": "sansayv15",
"ftpIp": null,
"ftpPort": null,
"ftpUserName": null,
"ftpPassword": null,
"sftpIp": null,
"sftpPort": null,
"sftpUserName": null,
"sftpPassword": null,
"name": "sansayv15",
"password": "root",
"userName": "root",
"perform": false,
"createBy": null,
"createDate": null,
"intId": 1,
"id": 1
}
]
Which comes as a output from my service. I utilize this output in two stores JsonResStore and ObjectStore over MemorryStore for the EnhancedGrid
I have grid structure defined in variable ,
var templateGridStructure = [ {
name : "ID",
field : "id",
hidden : "true"
}, {
name : "Name",
field : "name",
width : "auto"
}, {
name : "Collection Method",
field : "_item",
width : "auto",
formatter : function(item) {
return item.collectorType.name;
}
}, {
name : "Export Method",
field : "_item",
width : "auto",
formatter : function(item) {
return item.exportType.name;
}
}, {
name : "Source File Type",
field : "_item",
width : "auto",
formatter : function(item) {
return item.fileType.name;
}
},{
name : "Duplication Check",
field : "checkDuplicate",
width : "auto",
},{
name : "Validation Check",
field : "checkValidate",
width : "auto",
},{
name : "Switch Type",
field : "_item",
width : "auto",
formatter : function(item) {
return item.switchType.name;
}
} ];
When I use ObjectStore in EnhancedGrid
templateGrid = new dojox.grid.EnhancedGrid({
id : "templateGrid",
name : "templateGrid",
store : objectStore});
Grid is showing correct data But when I use JsonRestStore in EnhancedGrid
templateGrid = new dojox.grid.EnhancedGrid({
id : "templateGrid",
name : "templateGrid",
store : jsonRestStore});
I get error- grid is not showing data.
Is there any difference in defining column structure between these two stores.??
I found mistake, courtesy : Dojo IRC "Ravi: you shouldn't be accessing items of dojo/data stores directly" Instead of, directly using item in formatter method
{
name : "Switch Type",
field : "_item",
width : "auto",
formatter : function(item) {
return item.switchType.name;
}
}
use store.getValue(item,property), JsonRestStore, don't allow direct access to items
{
name : "Switch Type",
field : "_item",
width : "auto" ,
formatter : function(item) {
return store.getValue(item,"switchType").name;
}
}
I hope, somebody will get help from this