PDA

View Full Version : Add to store problems



bstras21
18 Feb 2011, 8:50 PM
I hope someone can help, I have been at this for hours. I can get my store to load directly from the server but I can't add to the store:

Model

var Emp = Ext.regModel('Employee', {
fields: [
{name: 'id', mapping: 0},
{name: 'firstName', mapping: 1},
{name: 'lastName', mapping: 2},
{name: 'group', mapping: 4}
]
});


Store

var store = new Ext.data.ArrayStore({
model : 'Employee',
sorters: 'lastName',

getGroupString : function(record) {
return record.get('lastName')[0];
},
proxy: {
type: 'ajax',
url : '../hosted/php/empCSV.php',
reader: {
type: 'json',
root: 'results'
}
},
//autoLoad: true

});

This is how the results look that I want to add: [["40166","Cheb","Howell","ALL","5","na"]]

Again this works with autoLoad. I have tired to create a new model:


var newData = new Emp([["40166","Cheb","Howell","ALL","5","na"]]);
Then I have tried:
store.load(newData);
store.loadData(newData);
store.loadRecords(newData);
store.add(newData);



I get this error a lot: Uncaught TypeError: Cannot read property 'length' of undefined
I can't get anything to work and help would be greatly appreciated, thanks!