【问题标题】:store sync data does not work存储同步数据不起作用
【发布时间】:2014-07-04 03:53:35
【问题描述】:

我的商店代码

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
            });
        }
    });

而且我不知道为什么我的控件的 detailStore.sync 无法工作。

没有任何错误代码。

完全没有回应....

而且我总是检查我的网络。

它没有请求。

【问题讨论】:

  • 尝试将update url 添加到您的api
  • 我添加完成。但没有回应.......
  • detailStore.sync这个方法完全没有Response....

标签: extjs extjs4 extjs4.2


【解决方案1】:

我不太确定你在问什么。为了使同步工作,您需要更改存储中的某些内容(修改、删除、添加),您需要代理上的编写器,当您然后调用 store.sync() 时,请求将发送到服务器。只有在那之后才有响应。

【讨论】:

  • 我问我不知道我的 store.sync() 没有工作。不过店里的设置还可以。
  • detailStoreautoSync:true,因此每次您在商店中更改某些内容时都应该看到一个请求。你能把它放在fiddle.sencha.com 上,这样我就可以看到它的实际效果了吗?
  • 我想把它放在 fiddle.sencha.com 上。
  • 我不知道如何使用fiddle.sencha.com。
  • 你有Skype吗??加我:maplescar520
【解决方案2】:

内部代理使您的 autoSync:false 。当 autoSync: true 时不需要调用 detailStore.sync({....})。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多