【发布时间】:2017-01-02 10:59:20
【问题描述】:
我有这家店:
商店
Ext.define('App.mystore', {
extend: 'Ext.data.Store',
model: 'App.mymodel',
autoLoad: false,
proxy: {
type: 'ajax',
api: {
read: 'read.php',
create: 'create.php',
update: 'update.php'
},
reader: {
type: 'json',
root: 'data',
totalProperty: 'total',
successProperty: 'success'
},
writer: {
root: 'records',
encode: true,
writeAllFields: false
}
}
});
这个商店是一个网格,点击一个按钮我可以添加一行,如果我选择一些以前的(插入数据库中的)行,我可以编辑它的数据。
完成后,我单击一个按钮将存储与数据库同步。
这个按钮用这个代码调用一个函数:
onSave:function(){
var Store=Ext.ComponentQuery.query('mygrid')[0].getStore();
Store.getProxy().setExtraParam('param1',this.Param1);
Store.getProxy().setExtraParam('param2',this.Param2);
Store.getProxy().setExtraParam('param3',this.Param3);
Store.sync({
scope:this,
success : function(response){
Ext.Msg.show({
title: 'Information',
msg: 'All OK',
icon: Ext.MessageBox.INFO,
buttons: Ext.Msg.OK
});
},
failure:function(response){
Ext.Msg.show({
title: 'warning',
msg: 'Error',
icon: Ext.MessageBox.WARNING,
buttons: Ext.Msg.OK
});
}
});
},
我可以分两步同步存储,首先是新记录,然后是修改记录?因为我需要知道这两个操作是否成功。因为用户可以添加新行并编辑一些旧行。
【问题讨论】: