行编辑时更新网格存储

时间:2016-05-09 14:10:19

标签: extjs extjs5

我正在尝试在RowEditing Update上更新商店点击

添加了一个监听器

 listeners: {                                            
               'edit': function (editor, e) { 
                    alert('Row Updating');
                 }
            }

警告在UPdate点击时触发,因此尝试现在更新商店,如下所示

1.var rec = e.record;                                                
  e.store.sync();
2. var timeGrid = this.up('grid');
   timeGrid.store.sync();

3. Ext.ComponentQuery.query('#gdItemId')[0].store.sync();

4. this.store.sync();

以上所有内容都无法更新要存储的已更改记录。 抛出错误为 -

Unhandled exception at line 1984, column 17 
0x80004005 - JavaScript runtime error: unknown exception

原因是什么?请建议我,我如何在这里更新数据。

正在更新:

添加完整代码 -

 Ext.define('TimeModel', {
extend: 'Ext.data.Model',
fields: [
    { name: 'stop_type_id', type: 'int' }
]
});
----------------------
var storeStop = new Ext.data.SimpleStore({
fields: ["value", "text"],
data: [
  [1, "Delivery"],
  [2, "Pickup"]
]
});
---------------------------
var comboBoxStopRenderer = function (comboStop) {
return function (value) {
    var idx = comboStop.store.find(comboStop.valueField, value);
    var rec = comboStop.store.getAt(idx);
    return (rec === null ? '' : rec.get(comboStop.displayField));
};
}
------------------------
var comboStop = new Ext.form.ComboBox({
store: storeStop,
valueField: "value",
displayField: "text"
 });
     
 xtype: 'grid',
 itemId: 'gdTimeCommitmentItemId',
 store: {
type: 'webapi',
api: {
    read: 'api/Report/GetTime'
},
autoLoad: false,
},
columns: [
        {
            text: 'Stop Type', dataIndex: 'stop_type_id', width: '12%', editor: comboStop, renderer: comboBoxStopRenderer(comboStop)
        }
    ],
 plugins: [rowEditingTime],
 tbar: [
{
text: 'Add',    
handler: function () {
    rowEditingTime.cancelEdit();
    var timeGrid = this.up('grid');
    var r = Ext.create('TimeModel', {
        stop_type_id: 1
    });
    timeGrid.store.insert(0, r);
    rowEditingTime.startEdit(0, 0);        
}
} ],                                      
listeners: {                                            
'edit': function (editor, e) {
    //alert('Updating');
    //var rec = e.record;                                                
    //e.store.sync();
    //var timeGrid = this.up('grid');
    //timeGrid.store.sync();
   // Ext.ComponentQuery.query('#gdTimeCommitmentItemId')[0].store.sync();
    //this.store.sync();
}
     

}

1 个答案:

答案 0 :(得分:0)

在您的问题中包含您的商店代理类。我认为您没有正确创建商店代理。

示例存储同步的代理

   proxy : 
{
    type : 'ajax',
    reader : 
    {
        root : 'data',
        type : 'json'
    },
    api : 
    {
        read : '/ExampleService.svc/students/',
        create: '/ExampleService.svc/createstudentbatch/',
        update : '/ExampleService.svc/updatestudentbatch/',
        destroy : '/ExampleService.svc/deletestudentbatch/'
    },
    actionMethods : 
    {
        destroy : 'POST',
        read : 'GET',
        create : 'POST',
        update : 'POST'
    }}
相关问题