For getting selected row in grid, I use this:
'#deleteWorkerButton': {
click: function(me, e, eOpts){
var grid = Ext.ComponentQuery.query('Worker')[0];
var selected = grid.getSelectionModel().getSelection()[0];
grid.getStore().remove(selected);
}
}
In my store, I have url for posting this JSON but when I use json_decode I get this:
object(stdClass) {
id => "5";
name => "tets";
email => "era@sdfsa.com";
phone => "test";
}
But I need array(), not stdClass.
This is my store:
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
});
So, I’m using this for DELETING data. What can I do with my store to get a “NORMAL” array when json_decode()?
I think the problem is in:
grid.getStore().remove(selected);
Just read the docs: