View Full Version : Records null in a callback

15 Mar 2011, 3:33 AM
Hello, i've not found this problem elewhere

I'm creating a store :

monstore = new Ext.extend(Ext.data.JsonStore, {
url: 'munurl',
root: 'data',
fields: [
{name: 'code'},
{name: 'name'},
{name: 'description'}

constructor: function(config) {
config = config || {};
config.fields = config.fields || this.fields;
config.root = config.root || this.root;
config.totalProperty = config.totalProperty || this.totalProperty;

monstore .superclass.constructor.call(this, config);

I use it and load it. I want to update a Form with the result
I'm in a Ext.form.FormPanel object

this.store = new monstore();
params: {
'id': 3219
callback: function(records, options, success){
scope: this

Here is what I get from my url after the load

{"success":true,"data":{"code":"Autoévaluation","description":null,"name":"A CUP OF TEA"}}

The probleme is : Extjs tells me that record is not defined

record is undefined

Indeed, even the "records" object is null
I don't understand why. I've got the same configuration on other projets and it works

Can someone tell me which error I did ?

15 Mar 2011, 5:31 AM
put in a

console.log(arguments); in your callback to verify the arguments.

15 Mar 2011, 5:38 AM

I've added this log and obtains the following arguments

[[], Object { params={...}, scope={...}}, true]

so :
- my records are null
- the success is "true"
- the params are what i've put in it, the id.... and some other stuff like scope and so

21 Mar 2011, 5:21 AM
Hi, still no answer on my side to solve this problem.
Does anyone has an hint ??

21 Mar 2011, 5:51 AM
I think the problem may be in "Autoévaluation". Escape that character (utf-8) or try without special html characters.

21 Mar 2011, 5:56 AM
héhé, I've already tried that, even without accent it doesn't works. Thanks for the idea

I've just found the solution :

My store lack the idProperty. If a field of my store is named 'id', it will take it by default (it's my other component which worked). But there is not 'id' field and the store can't find proper dataRecord

I think there's a lack ok proper error message to show that...

The solution is to add a 'id' field or to add idProperty: 'code' for my example.


22 Mar 2011, 7:23 AM
I had some experience with special HTML-chars in the json, which became the waterloo of the transaction, so I first thought of that :)
Glad you found it :)

25 Mar 2011, 7:31 PM
data field on the JSON result should be an array, not Object.

{"success":true,"data":[{"code":"Autoévaluation","description":null,"name":"A CUP OF TEA"}]}