Php 删除网格中的行时出现奇怪的JSON(Ext JS 4)
要获取网格中的选定行,我使用以下方法:Php 删除网格中的行时出现奇怪的JSON(Ext JS 4),php,javascript,extjs,extjs4,Php,Javascript,Extjs,Extjs4,要获取网格中的选定行,我使用以下方法: '#deleteWorkerButton': { click: function(me, e, eOpts){ var grid = Ext.ComponentQuery.query('Worker')[0]; var selected = grid.getSelectionModel().getSelection()[0];
'#deleteWorkerButton': {
click: function(me, e, eOpts){
var grid = Ext.ComponentQuery.query('Worker')[0];
var selected = grid.getSelectionModel().getSelection()[0];
grid.getStore().remove(selected);
}
}
在我的商店中,我有发布此JSON的url,但当我使用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()时,如何使用我的存储来获得“正常”数组
我认为问题在于:
grid.getStore().remove(selected);
读一下:
混合json_解码(字符串$json[,bool$assoc=false[,int$depth=512[,int$options=0]])[…]
协会 如果为TRUE,则返回的对象将转换为关联数组 读一下: 混合json_解码(字符串$json[,bool$assoc=false[,int$depth=512[,int$options=0]])
[…]
协会 如果为TRUE,则返回的对象将转换为关联数组
尝试将
allowSingle:false
添加到写入程序配置中。默认情况下,它设置为true,这意味着在不使用数组换行的情况下发送单记录更改。尝试将allowSingle:false
添加到写入器配置中。默认情况下,它设置为true,这意味着在不使用数组换行的情况下发送单记录更改。感谢您的响应,但@Alvaro的回答是正确的+谢谢你告诉我一些新的事情谢谢你的回复,但@Alvaro的回答是正确的+谢谢你告诉我一些新的事情D