我的商店代码
Ext.define('Console.store.SubjectMaterial.DetailStore', {
extend: 'Ext.data.Store',
model: 'Console.model.SubjectMaterial.DetailModel',
proxy: {
actionMethods: 'POST',
type: 'ajax',
api: {
create: './modules/source/controller/SubjectMaterial/insertDetail.php',
read: './modules/source/store/SubjectMaterial/selectDetail.php',
destroy: './modules/source/controller/SubjectMaterial/deleteDetail.php'
},
reader: {
type: 'json',
root: 'result'
},
writer: {
type: 'json',
root: 'data',
encode: true
}
},
sorters: {
direction: 'ASC',
property: 'material_name'
},
remoteSort: true,
autoLoad: false,
autoSync: true
});
我的模型代码
Ext.define('Console.model.SubjectMaterial.DetailModel',{
extend:'Ext.data.Model',
fields:[
{
name:'material_id',
type:'string'
},{
name:'material_name',
type:'string'
},{
name:'material_version',
type:'string'
},{
name:'material_picture',
type:'string'
},{
name:'material_detail',
type:'string'
},{
name:'material_url',
type:'string'
},{
name: 'material_size',
type: 'string'
},{
name: 'material_author',
type: 'string'
},{
name: 'subject_share',
type: 'string'
},{
name: 'subject_secure',
type: 'string'
},{
name: 'material_create_date',
type: 'string'
},{
name: 'material_update_date',
type: 'string'
}]
});
我的控制器代码
detailInsertConfirm: function(obj, e, eOpts) {
var masterSelectedRecord = Ext.getCmp('sumagridmaster').getSelectionModel().getSelection()[0];
var detailStore = Ext.getCmp('sumagriddetail').store;
var actionPanel = obj.up('sumaactionpanel');
var gridPanel = obj.up('sumaformdetailinsert');
// console.log(gridPanel);
// var formPanel = gridPanel.getForm();
//insert
detailStore.add(gridPanel.getSelectionModel().getSelection());
// detailStore.add(masterSelectedRecord);
console.log(detailStore.data);
// console.log(gridPanel.getSelectionModel().getSelection());
detailStore.sync({
callback: function(batch, options) {
// body...
console.log('this is callback.');
},
success: function(batch, options) {
console.log('this is success.');
Ext.MessageBox.show({
title: MSG['universal_msg_box_header_text'],
icon: Ext.MessageBox.INFO,
msg: MSG['universal_msg_box_content_insert_success'],
closable: false,
buttons: Ext.MessageBox.OK,
fn: function(buttonId,text,opt){
if (buttonId == 'ok') {
detailStore.reload();
}
}
});
},
failure: function(batch, options) {
console.log('this is failure.');
Ext.MessageBox.show({
titel: MSG['universal_msg_box_header_text'],
icon: Ext.MessageBox.ERROR,
msg: MSG['universal_msg_box_content_insert_fail'],
closable: false,
buttons: Ext.MessageBox.OK
});
}
});
而且我不知道为什么我的controll的detailStore.sync无法正常工作。
没有任何错误代码。
完全没有回应......
我总是检查我的网络。
没有任何要求。
答案 0 :(得分:0)
我不太确定你在问什么。要使同步工作,您需要更改商店中的内容(修改,删除,添加),您需要代理上的编写器,当您然后调用store.sync()
时,请求是发送到服务器。只有在那之后才会收到回复。
答案 1 :(得分:0)
内部代理使您的autoSync:false。当autoSync:true时,则无需调用detailStore.sync({....})。