PDA

View Full Version : [solved] undefined field mapping on RESTful JsonStore save



GDW
13 Dec 2009, 5:50 PM
I'm trying to get the RESTful WS functionality working with JsonStore/EditorGridPanel. The grid loads fine but when saving the changes, the fields are passed as a map named "undefined" (see Firebug output on attached screenshot). What am I doing wrong?

Thanks,
Gary

Code:



var textFieldEditor = new Ext.form.TextField();

var accountCM = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{
id: 'id',
header: "ID",
dataIndex: 'id',
width: 150,
hidden: true
},
{
header: "First Name",
dataIndex: 'firstname',
sortable : true,
editor : textFieldEditor,
width: 150
},
{
header: "Last Name",
dataIndex: 'lastname',
sortable : true,
editor : textFieldEditor,
width: 150
},
{
header: "Username",
dataIndex: 'username',
sortable : true,
editor : textFieldEditor,
width: 150
},
{
header: "Email",
dataIndex: 'email',
sortable : true,
editor : textFieldEditor,
width: 150
}
]);
accountCM.defaultSortable = true;

var accountStore = new Ext.data.JsonStore({
id: 'account',
url: 'accounts',
remoteSort: true,
restful: true,
writer: new Ext.data.JsonWriter(),
autoSave: true,
batch: true,
fields: [] // initialized from json metadata
});
accountStore.setDefaultSort('lastname', 'ASC');

var grid = new Ext.grid.EditorGridPanel({
id: 'list-account-panel',
renderTo: "account-grid",
ds: accountStore,
cm: accountCM,
viewConfig: {forceFit:true},
height:400,
width:800,
frame: true,
autoScroll:true
});

// trigger the data store load
accountStore.load();

GDW
13 Dec 2009, 9:26 PM
added root: 'account'

to JsonStore