Hi everyone,
I'm facing an issue in using 'Ext.util.JSON.encode( )' method and I don't know how to overcome it.
This is the situation: I have a grid filled by a data store called branch_store, the grid has got an action column containing a button to delete currently selected row.
I want to send a JSON string containing currently selected row's id to a php script named 'delete.php': it will delete corresponding record from a table in a database.
Here's my code:
Code:
var rec = branch_store.getAt(rowIndex);
var id = rec.get('id');
alert("Id is: "+id); //Debug code
var store = Ext.create('Ext.data.ArrayStore', {
fields: ['id'],
data : [[id]]
});
Ext.Ajax.request({
url: 'delete.php',
success: function() { Ext.Msg.alert('Success'); },
failure: function() { Ext.Msg.alert('Fail'); },
jsonData: Ext.util.JSON.encode(store.data)
});
The code above doesn't work, by using google chrome's javascript console to debug it I obtain the following error message:
Uncaught TypeError: Cannot call method 'encode' of undefined
The problem is clearly the argument passed to 'encode' method, but I don't know what should be the correct argument type for that method.
Can anyone help me ?
Thanks in advance.