【发布时间】:2014-09-14 17:49:22
【问题描述】:
我的 ExtJS 4.2.1 应用程序中有一个带有以下可编辑列的网格:
text: 'Location',
dataIndex: 'LocationId',
width: 140,
renderer: function(value) {
var record = me.store.findRecord('LocationId', value);
return record.get('Description');
},
editor: {
xtype: 'combobox',
typeAhead: true,
triggerAction: 'all',
store: Ext.create('App.store.catalog.Location', {
autoLoad: true
}),
displayField: 'Description',
valueField: 'LocationId',
listConfig: {
width: 250,
loadingText: 'Searching...',
// Custom rendering template for each item
getInnerTpl: function() {
return '<b>{Code}</b><br/>(<span style="font-size:0.8em;">{Description}</span>)';
}
}
}
组合有一个renderer 来显示所选LocationId 的描述。
然后,我的网格具有 'Ext.grid.plugin.CellEditing' 功能,因此我可以只编辑该列单元格。
我遇到的问题是当我按下“Update”按钮时,即使记录中的LocationId具有正确的值,组合显示值也会恢复到原来的值。
这是我在用户按下“更新”按钮时触发的代码。
me.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false,
listeners: {
edit: function(editor, e) {
var record = e.record;
me.setLoading('Updating...');
App.util.Ajax.request({
noMask: true,
url: '/api/catalog/UpdateEmployeeLocation',
jsonData: record.getData(),
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
if (obj.success) {
// commit changes (no save just clear the dirty icon)
me.getStore().commitChanges();
}
},
callback: function() {
me.setLoading(false);
}
});
}
}
});
记录已正确保存在我的数据库中,但组合显示值未使用与LocationId 对应的描述进行更新。如果我再次从服务器重新加载商店,那么它会正确显示。
所以,我的列中的
renderer有问题,在我更新记录后没有更新值。
关于如何解决这个问题的任何线索?
谢谢。
【问题讨论】:
标签: extjs extjs4 extjs4.1 extjs4.2 extjs-mvc