PDA

View Full Version : jsonstore record is undefined



irizzant
12 May 2010, 2:04 AM
Hello,
I am having this problem while working in append mode with a jsonstore.
Let's consider this store and associated grid:


var masterAssociationStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '....',
}),
baseParams: {
start: 0,
limit: thePageSize
}
});

var sm = new Ext.grid.CheckboxSelectionModel({
checkOnly: true
});

var masterGrid = new Ext.grid.GridPanel({
store: masterAssociationStore,
loadMask: true,
title: "Currently Associated Invoices",
frame: true,
height: 200,
defaults: {
sortable: true,
width: 150,
resizable: true
},
selModel: sm,
columns: [
sm, {
dataIndex: "masterInvoiceId",
header: "masterInvoiceId"
},
{
dataIndex: "masterInvoiceNumber",
header: "masterInvoiceNumber"
},
{
dataIndex: "mawbMbl",
header: "mawbMbl"
},
{
dataIndex: "hawbHbl",
header: "hawbHbl"
},
{
xtype: "datecolumn",
format: "d/m/Y",
dataIndex: "createdOn",
header: "createdOn"
}],
tbar: [{
text: 'Search',
handler: function () {
masterAssociationWin.show();
},
iconCls: 'icon-find'
}]
});


where masterAssociationWin is a window in which I have a form used for searching items to add to the grid.
This is the code I use to add records to the grid when I submit the form mentioned above:


invoiceAssociationSearchForm.getForm().submit({
waitMsg: 'Submitting data...',
success: function (form, action) {
masterAssociationStore.loadData(action.result, true);
},
failure: function (form, action) {
switch (action.failureType) {
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.show({
title: 'Error',
msg: 'Server communication error',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.show({
title: 'Error',
msg: action.result.message,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
}
});

where invoiceAssociationSearchForm is the submitted form.
Whenever the action returns records already existing in the store, I get an error:


record is undefined
meta.value = column.re..., meta, record, rowIndex, i, store); ext-all-debug.js (row 68448)


I am using Extjs ver. 3.2.0.
I've already read about each record must having its own ID, so it could be the problem.
But any workaround to work in append mode even if there are records with the same id already in the store?

I thought the
loadData(action.result, true); would have avoided this kind of problems...:((:((

13 May 2010, 4:39 AM
You need to configure "fields" or a "record". look at the examples

irizzant
17 May 2010, 5:06 AM
Thanks a lot for your reply,
I am trying to use an automatically configured jsonstore as masterAssociationStore, so I supposed the "fields" configuration would have been read from the server response in the "metadata" property.
Does the jsonstore need to be configured initially with an empty array as "fields" property?
Thanks again

Condor
17 May 2010, 5:21 AM
Yes, you should indeed initialize the reader with fields:[].

ps. It's metaData and not metadata.

irizzant
17 May 2010, 7:04 AM
Thanks, I'll try and post the results.


ps. It's metaData and not metadata.

Right, it's a typing error ;)

irizzant
19 May 2010, 4:18 AM
Ok, it works, thanks!