1chiban
29 Aug 2011, 8:49 AM
Hi guys,
I have a json file with the data i want to put in my list but apparently it doesn't load any data. When i try to run the program it keeps loading and loading and it gives me the following error:"Cannot read property 'length' of undefined". I think it refers to the records.length so it means basically it's not loading anything into the store.
This is my Json file:
{'cars': [{ "id": 1,
},
{
"id": 2,
},
{
"id": 3,
},
{
"id": 4,
},
{
"id": 5,
}],
'brands': [
{
"id": 1,
"car_id": 1,
"brand": "Mercedes"
},
{
"id": 2,
"car_id": 2,
"brand": "Ferrari"
},
{
"id": 3,
"car_id": 1,
"brand": "Lotus"
},
{
"id": 4,
"car_id": 3,
"brand": "Volvo"
},
{
"id": 5,
"car_id": 4,
"brand": "Opel"
},
{
"id": 6,
"car_id": 4,
"brand": "WW"
}]
}
And this is my store, list and model:
Auto.models.Brand= Ext.regModel('Brand', {
idProperty:'id',
fields: [
{name: 'id', type:'int'},
{name: 'car_id', type:'int'},
{name: 'brand', type:'string'}
],
belongsTo: 'Car',
proxy: {
type: 'ajax',
url: '../data.json',
reader: {
type: 'json',
root: 'brands'
}
}
});
Auto.models.Car= Ext.regModel('Car', {
idProperty: 'id',
fields: [
{name: 'id', type:'int'},
],
associations:[
{type:'hasMany', model:'Brand', name:'brands'}
],
proxy: {
type: 'ajax',
url: '../data.json',
reader: {
type: 'json',
root: 'cars'
}
},
});
Auto.stores.Car= new Ext.data.Store({ model: "Car",
autoLoad: true
});
Auto.stores.Brand= new Ext.data.Store({
model: "Brand",
autoLoad: true
});
Auto.views.CarList = new Ext.List({
store: TPL.stores.Car,
itemTpl: '<span id="{id}">{id}</span>'
});
Any idea how about what could be wrong?:s
I have a json file with the data i want to put in my list but apparently it doesn't load any data. When i try to run the program it keeps loading and loading and it gives me the following error:"Cannot read property 'length' of undefined". I think it refers to the records.length so it means basically it's not loading anything into the store.
This is my Json file:
{'cars': [{ "id": 1,
},
{
"id": 2,
},
{
"id": 3,
},
{
"id": 4,
},
{
"id": 5,
}],
'brands': [
{
"id": 1,
"car_id": 1,
"brand": "Mercedes"
},
{
"id": 2,
"car_id": 2,
"brand": "Ferrari"
},
{
"id": 3,
"car_id": 1,
"brand": "Lotus"
},
{
"id": 4,
"car_id": 3,
"brand": "Volvo"
},
{
"id": 5,
"car_id": 4,
"brand": "Opel"
},
{
"id": 6,
"car_id": 4,
"brand": "WW"
}]
}
And this is my store, list and model:
Auto.models.Brand= Ext.regModel('Brand', {
idProperty:'id',
fields: [
{name: 'id', type:'int'},
{name: 'car_id', type:'int'},
{name: 'brand', type:'string'}
],
belongsTo: 'Car',
proxy: {
type: 'ajax',
url: '../data.json',
reader: {
type: 'json',
root: 'brands'
}
}
});
Auto.models.Car= Ext.regModel('Car', {
idProperty: 'id',
fields: [
{name: 'id', type:'int'},
],
associations:[
{type:'hasMany', model:'Brand', name:'brands'}
],
proxy: {
type: 'ajax',
url: '../data.json',
reader: {
type: 'json',
root: 'cars'
}
},
});
Auto.stores.Car= new Ext.data.Store({ model: "Car",
autoLoad: true
});
Auto.stores.Brand= new Ext.data.Store({
model: "Brand",
autoLoad: true
});
Auto.views.CarList = new Ext.List({
store: TPL.stores.Car,
itemTpl: '<span id="{id}">{id}</span>'
});
Any idea how about what could be wrong?:s