PDA

View Full Version : store.save no solution



Nokiwood
29 Apr 2013, 8:04 PM
Hello,

My version of ExtJS is 4.2

I develope a small application and I can not update my MySQL database.


When I make a store.save (record) the php file via AJAX (proxy) is not called and no updated ??...


Someone already had this problem? Can someone help me?

My store file:


Ext.define('Adresses.store.Adresses', {
extend: 'Ext.data.Store',


model: 'Adresses.model.Adresses',
autoLoad: true,
proxy:{
type: 'ajax',
api:{ create: 'Adresses/php/Adresses/.php?action=create',
read: 'Adresses/php/Adresses.php?action=read',
update: 'Adresses/php/Adresses.php?action=update',
destroy:'Adresses/php/Adresses.php?action=destroy'},
reader:{ type:'json', root:'data', successProperty:'success' } ,
writer:{ type:'json', root:'data', successProperty:'success' }
}


});

My controler file :



Ext.define('Adresses.controller.Adresses', {
extend: 'Ext.app.Controller',
stores: ['Adresses'],
models: ['Adresses'],

views: [
'Adresses.view.Adresses.Liste',
'Adresses.view.Adresses.Ajouter',
'Adresses.view.Adresses.Modifier'
],



init: function() {
this.control({
'viewport > panel': {
render: this.onPanelRendered
},
'adresseliste': {
//itemclick: this.affectebtn,
itemdblclick: this.editer
},
'adressemodifier button[action=save]': {
click: this.updateRecord
}

});
},

updateRecord: function(button) {

var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);

win.close();

var store = Ext.getStore('Adresses');
store.save( record );
store.sync();
},


editer: function(grid, record) {
var view = Ext.widget('adressemodifier',
{'width': '300', 'height':'300'});


view.down('form').loadRecord(record);
},


onPanelRendered: function() {
console.log('Le panneau a été rendue');
}
});

slemmon
1 May 2013, 1:47 PM
The store doesn't have a save method, but does have a commitChanges() method. Try that before the sync().