0

我有一个像

[
    {
        "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 中使用此输出而不是 MemoryStore 用于 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});

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

这两个商店之间定义列结构有什么区别吗??

4

1 回答 1

0

我发现了错误,礼貌:Dojo IRC“Ravi:你不应该直接访问 dojo/数据存储的项目”而不是直接使用格式化程序方法中的项目

{
        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;
        } 
    }

我希望,有人会从中得到帮助

于 2012-06-07T15:29:48.317 回答