0

我有以下型号和商店。

模型:

Ext.define('TruckTask.model.Company', {
extend: 'Ext.data.Model',

idProperty: 'id',

fields: [
    {name: 'id',  type: 'int', defaultValue: null},
    {name: 'name',  type: 'string'},
    {name: 'site',  type: 'string'},
    {name: 'createdDate',  type: 'date',
        convert: function(rawValue, model) {

    var intDate = parseInt(rawValue);

            if(intDate > 0){
                return Ext.util.Format.date(new Date(intDate), 'd.m.Y');
            }

            if(typeof(rawValue) == 'object'){
                return rawValue;
            }
        }
    },
    {name: 'langId',  type: 'int'}
]

});

店铺:

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

requires : [
    'TruckTask.model.Company',
    'TruckTask.config.SecureRestProxy'
],

alias: 'store.company',

storeId: 'company',

model   : 'TruckTask.model.Company',

autoLoad: true,
autoSync: true,

proxy: {
    type: 'secure-rest',
    reader: {
        type: 'json'
    },
    writer: {
        type: 'json'
    },
    api: {
        read: '/api/company',
        create: '/api/company',
        update: '/api/company',
        destroy: '/api/company'
    }
}

});

我使用网格面板来列出这个模型。但是我通过另一种形式创建新模型。

在网格中我定义商店:

    store: {
    type: 'company'
},

并且表单的提交处理程序具有实现:

var record = this.getViewModel().get('rec');
    var companyStore = Ext.data.StoreManager.lookup('company');
    companyStore.add(record);

因此记录立即出现在网格面板中,但没有 createdDate 字段值。该值来自服务器响应。

当我得到服务器响应时,如何在网格面板中更新此记录?

4

1 回答 1

0

我想你会发现这个答案很有用。在您的商店中实施onCreateRecords并设置在创建和保存新记录后需要设置的任何内容。

于 2017-01-07T09:57:57.450 回答