我商店中的所有数据都嵌套在一行

时间:2016-08-12 13:57:01

标签: extjs6

我在文件夹extjs6.0.2(http://examples.sencha.com/extjs/6.0.2/examples/admin-dashboard/#dashboard)中使用admin-dashboard作为模板,我使用“后端和php mysql”(http://docs.sencha.com/extjs/6.0.2-classic/guides/backend_connectors/direct/mysql_php.html)指南“后端连接器”。

我在“用户结果”中将商店更改为“搜索结果”时出现问题。我用后端连接器指南的改编版本替换了静态存储。

Router.php以json格式正确提供数据,但我在网格面板用户结果中只有一个空行。

这是我的商店

Ext.define('Admin.store.import.Users', {
extend: 'Ext.data.Store',

alias: 'store.importusers',

fields: [
    {type: 'int', name: 'id'},
    {type: 'string', name: 'szNomUser'},
    {type: 'string', name: 'szPrenomUser'},
    {type : 'string', name: 'szLoginUser'},
    {type: 'string', name: 'szMailUser'}
],

proxy: {
    type: 'direct',
    api: {
        read: 'QueryDatabase.getUsers'
    },
    reader: {
        type: 'json'
    }
},
autoLoad : true
});

来自查询的结果

{
"type": "rpc",
"tid": 1,
"action": "QueryDatabase",
"method": "getUsers",
"result": {
    "0": {
        "id": "2",
        "szNomUser": "ADMINISTRATEUR",
        "szPrenomUser": "Default",
        "szLoginUser": "admin",
        "szPassWordUser": "admin",
        "szProfilUser": "S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4S",
        "nLangueUser": "1",
        "nRefIdStudioUser": "0",
        "szSuperviseurUser": "0",
        "szTelUser": "",
        "szFaxUser": "",
        "szMobileUser": "",
        "szMailUser": "martinbryan.eu@gmail.com",
        "tDateNaissanceUser": "2004-12-08",
        "bActifUser": "1",
        "szModeWeb": "0",
        "szSuperSuperviseurUser": "0",
        "szGroupUser": "T",
        "szActiviteUser": "1"
    },
    "1": {
        "id": "18",
        "szNomUser": "DETTO",
        "szPrenomUser": "ERNEST",
        "szLoginUser": "ED",
        "szPassWordUser": "ED",
        "szProfilUser": "S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4S\u00a4N",
        "nLangueUser": "1",
        "nRefIdStudioUser": "0",
        "szSuperviseurUser": "0",
        "szTelUser": "",
        "szFaxUser": "",
        "szMobileUser": "",
        "szMailUser": "",
        "tDateNaissanceUser": "0000-00-00",
        "bActifUser": "0",
        "szModeWeb": "0",
        "szSuperSuperviseurUser": "0",
        "szGroupUser": "",
        "szActiviteUser": "1"
    }
}
}

当我查看我的gridpanel商店时,我有这棵树:

商店>数据(长度1)>项目(长度1)> [0]>数据    在最后的数据中我拥有所有数据,所有字段都是空的。    而这个例外 Ext.data.Model #persistenceProperty 在最后一个数据的属性集之前。

当然我的gridpanel列有正确的dataIndex。

1 个答案:

答案 0 :(得分:0)

阱,

我的数据没有正确格式化,我查看了extjs 6中的直接规范http://docs.sencha.com/extjs/6.0.2-classic/guides/backend_connectors/direct/specification.html#backend_connectors--direct--specification_-_remoting_responses)这不清楚数据是否必须是json对象或json数组宾语。在我的例子中,json对象的数组工作正常。

result — The data returned by the Method. 
MUST be present in the Response object, 
but MAY be null for Methods that do not return any data.


{
"type": "rpc",
"tid": 1,
"action": "QueryDatabase",
"method": "getUsers",
"result": [{
    "nIdUser": "2",
    "szNomUser": "ADMINISTRATEUR",
    "szPrenomUser": "Default",
    "szMailUser": "martinbryan.eu@gmail.com",
    "szLoginUser": "admin"
}, {
    "nIdUser": "18",
    "szNomUser": "DETTO",
    "szPrenomUser": "ERNEST",
    "szMailUser": "",
    "szLoginUser": "ED"
}]
}