繁体   English   中英

删除网格中的行时出现奇怪的JSON(Ext-JS 4)

[英]Strange JSON when deleting row in grid (Ext-JS 4)

为了获得网格中的选定行,我使用以下方法:

'#deleteWorkerButton': {
                click: function(me, e, eOpts){
                    var grid = Ext.ComponentQuery.query('Worker')[0];
                    var selected = grid.getSelectionModel().getSelection()[0];

                    grid.getStore().remove(selected);
                }
            }

在我的商店中,我有发布此JSON的网址,但是当我使用json_decode时,我得到了以下信息:

object(stdClass) {
    id => "5";
    name => "tets";
    email => "era@sdfsa.com";
    phone => "test";
}

但是我需要array() ,而不是stdClass

这是我的商店:

Ext.define('Sabrina.store.Workers', {
    extend: 'Ext.data.Store',
    fields:['id', 'name', 'email', 'phone'],
    proxy: {
        type: 'ajax',
        api: {
            create  : 'php/usuarios.php?action=insert',
            read    : '../mega_sabrina_cake/workers/index',
            update  : 'php/usuarios.php?action=update',
            destroy : '../mega_sabrina_cake/workers/delete'
        },
        actionMethods: {
            create  : 'POST',
            read    : 'POST',
            update  : 'POST',
            destroy : 'POST'
        },
        reader: {
            type: 'json',
            root: 'Worker',
            rootProperty: 'Worker',
            successProperty: 'success',
            messageProperty: 'message'
        },
        writer: {
            type: 'json',
            writeAllFields: true,
            root: 'data',
            encode: true
        },
    },
    autoLoad: true,
    autoSync: true
});

因此,我正在使用它来删除数据。 在json_decode()时,我该如何处理我的商店以获取“ NORMAL”数组?

我认为问题出在:

grid.getStore().remove(selected);

只需阅读文档

混合json_decode(字符串$ json [, bool $ assoc = false [,int $ depth = 512 [,int $ options = 0]]])
[...]
assoc为 TRUE时,返回的对象将转换为关联数组。

尝试在writer配置中添加allowSingle: false 默认情况下,它设置为true,这意味着不进行数组换行就发送单个记录更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM