PDA

View Full Version : Newbie - my get and update URLS called via ajax proxy aren't working



lcuff
16 Dec 2011, 5:18 PM
I'm writing my first app, and trying to get a basic read and update interface working via ajax proxy. I haven't yet found how to get either the read or update url called at all. Here's what I've got so far. Any and all help appreciated.

(I never see a log message saying my URL has actually been called)



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
proxy: {
type : 'ajax',
url : 'get_simpsons',
reader: {
type: 'json',
root: 'items'
},
writer: {
type : 'json',
encode : 'true'
},
api: {
read : 'get_simpsons',
update : 'submit_simpsons',
create : 'create_simpsons',
destroy : 'destroy_simpsons',
}
}
});


var panel1 = Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'Email', dataIndex: 'email', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{header: 'Phone', dataIndex: 'phone'}
],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});


Ext.onReady(function(){


main_container = Ext.create('Ext.container.Viewport', {
layout: 'column',
items: [ panel1 ]
});
});

skirtle
16 Dec 2011, 5:26 PM
I don't see anything telling the store to load. Add in autoLoad: true on the store.

Beware of stray commas, you have a couple already.

Also this:


store: Ext.data.StoreManager.lookup('simpsonsStore'),

can just be this:


store: 'simpsonsStore',

lcuff
16 Dec 2011, 5:45 PM
Thanks for the quick reply. That fixed the read problem, now is there something I'm doing wrong to get the update URL called?

skirtle
16 Dec 2011, 6:14 PM
I don't see any code telling it to do the save.

You could call save on the individual model.

You could call sync on the store.

You could set autoSync: true on the store.

Take your pick.