Dojo Enhaced Grid - JsonRestStore,Grid在使用JsonRestStore时不显示数据

时间:2012-06-07 11:13:32

标签: javascript dojox.grid dojo

我有一个喜欢

的json
[
    {
        "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
    }
]

这是我服务的输出。 我在两个存储区JsonResStore和ObjectStore上使用此输出而不是MemorryStore用于EnhancedGrid

我在变量

中定义了网格结构
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;
        }
    } ];

当我在EnhancedGrid中使用ObjectStore

templateGrid = new dojox.grid.EnhancedGrid({
                id : "templateGrid",
                name : "templateGrid",
                store : objectStore});

网格显示正确的数据 但是当我在EnhancedGrid中使用JsonRestStore

templateGrid = new dojox.grid.EnhancedGrid({
                id : "templateGrid",
                name : "templateGrid",
                store : jsonRestStore});

我收到错误 - 网格没有显示数据。

在这两个商店之间定义列结构是否有任何区别。??

1 个答案:

答案 0 :(得分:0)

我发现了错误,礼貌:Dojo IRC “Ravi:您不应该直接访问道场/数据存储项目” 而不是直接在formatter方法中使用item

{
        name : "Switch Type",
        field : "_item",
        width : "auto",
        formatter : function(item) {
            return item.switchType.name;
        }
    }

使用store.getValue(item,property),JsonRestStore,不允许直接访问项目

{
        name : "Switch Type",
        field : "_item",
        width : "auto" ,
        formatter : function(item) {
            return store.getValue(item,"switchType").name;
        } 
    }

我希望,有人会从这个

获得帮助