繼續與我的應用程序,其目的是要能夠編輯一個聚合的字段,並存儲在另一個領域的該聚合的各種組件的計算結果...行編輯似乎沒有更新底層商店
我現在能夠使用UserStory模型的擴展名正確檢索我的字段,但仍然無法保存我的更改。 我想檢查在Ext.grid.plugin.RowEditing的編輯事件中做了什麼,我注意到當我到達它時,e.store.data.items [rowIdx] .data包含我所有的期望值,它的髒和編輯標誌是錯誤的,但e.store.data.items [rowIdx] .raw不反映(它包含拉力賽的原始值,未修改) - 即使我嘗試編輯原始值,但它不起作用:
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1,
listeners: {
'edit': function (editor, e) {
e.store.data.items[e.rowIdx].raw.BusinessValues =
e.store.data.items[e.rowIdx].data.BusinessValues;
e.store.commitChanges();
}
}
})
]
整個代碼如下,但我想知道是否應該在模型級別添加一個偵聽器?
Rally.onReady(function() {
Ext.define('BVApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'UserStory',
success: function(model) {
var weights = new Array(5, 3, 1, 3, 4, 4, 2, 2);
var BvTitles = new Array("Customers Impact", "Critical Path", "Usability", "Functionality", "Security", "Performance", "Integration", "Integrity", "Business Value");
//var BvTitlesFrench = new Array("Parc Client", "Chemin Critique", "Ergonomie", "Fonctionnalité", "Sécurité", "Performance", "Intégration", "Intégrité", "Valeur Métier");
// Thanks to question http://stackoverflow.com/questions/12517383/sdk2-links-in-rally-grids-and-column-width I can now remove flex from FormattedID column...
var fixedIDwithLink = Rally.ui.grid.FieldColumnFactory.getColumnConfigFromField(model.getField('FormattedID'));
fixedIDwithLink.flex = false;
fixedIDwithLink.width = 70;
function getOneBV(record, pos, newValue) {
var ls_BvFieldStart, ls_BvFieldEnd, ls_BvFromBvField;
if (pos < 1) return newValue; // ERROR in fact...
if (pos > 8) return newValue;
ls_BvFieldStart = record.data.BusinessValues.substring(0, pos-1);
ls_BvFromBvField = record.data.BusinessValues.substring(pos-1, pos);
ls_BvFieldEnd = record.data.BusinessValues.substring(pos, 8);
if (newValue) {
ls_BvFromBvField = newValue;
record.data.BusinessValues = ls_BvFieldStart + ls_BvFromBvField + ls_BvFieldEnd;
}
return ls_BvFromBvField;
}
function getbv(as_bvHolder) {
var li_bv1, li_bv2, li_bv3, li_bv4, li_bv5, li_bv6, li_bv7, li_bv8, li_bvtotal;
li_bv1 = as_bvHolder.substring(0,1);
li_bv2 = as_bvHolder.substring(1,2);
li_bv3 = as_bvHolder.substring(2,3);
li_bv4 = as_bvHolder.substring(3,4);
li_bv5 = as_bvHolder.substring(4,5);
li_bv6 = as_bvHolder.substring(5,6);
li_bv7 = as_bvHolder.substring(7,8);
li_bv8 = as_bvHolder.substring(8,9);
li_bvtotal =
li_bv1*weights[0] +
li_bv2*weights[1] +
li_bv3*weights[2] +
li_bv4*weights[3] +
li_bv5*weights[4] +
li_bv6*weights[5] +
li_bv7*weights[6] +
li_bv8*weights[7];
return li_bvtotal;
}
this.grid = this.add({
xtype: 'rallygrid',
model: Ext.define('BVModel', {
extend: model,
alias : 'BVModel',
fields: [
{name: 'Bv1', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 1, v); }
},
{name: 'Bv2', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 2, v); }
},
{name: 'Bv3', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 3, v); }
},
{name: 'Bv4', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 4, v); }
},
{name: 'Bv5', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 5, v); }
},
{name: 'Bv6', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 6, v); }
},
{name: 'Bv7', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 7, v); }
},
{name: 'Bv8', type: 'string', persist: false,
convert: function(v, record){ return getOneBV(record, 8, v); }
},
{name: 'BvTotal', type: 'string', persist: false,
convert: function(v, record) {
var ls_scoreInfo = '';
if (record.data.BusinessValues) {
ls_scoreInfo = getbv(record.data.BusinessValues) + ' ';
}
if (record.data.Score) {
ls_scoreInfo += '(previous: ' + record.data.Score + ')';
}
return ls_scoreInfo;
}
}
]
}),
storeConfig: {
pageSize: 30, autoLoad: true, filters: [
{
property: 'ScheduleState',
operator: '=',
value: 'Backlog'
}
//,{ property: 'FormattedID', value: 'US85792' } // US85792, US84529, US81387, US77032
],
context: this.getContext().getDataContext()
},
columnCfgs: [
fixedIDwithLink, // might want to add a select listener later to display details in a child pane ?
'Name',
'BusinessValues',
'AffectedCustomers',
{
text: BvTitles[0], dataIndex: 'Bv1', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[1], dataIndex: 'Bv2', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[2], dataIndex: 'Bv3', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[3], dataIndex: 'Bv4', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[4], dataIndex: 'Bv5', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[5], dataIndex: 'Bv6', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[6], dataIndex: 'Bv7', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[7], dataIndex: 'Bv8', editor: { xtype: 'textfield' }, width: 70
},
{
text: BvTitles[8], dataIndex: 'BvTotal', editor: { xtype: 'textfield' }
}
],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1,
listeners: {
'edit': function (editor, e) {
e.store.data.items[e.rowIdx].raw.BusinessValues = e.store.data.items[e.rowIdx].data.BusinessValues;
e.store.commitChanges();
}
}
})
]
});
}, // end of getModel success
scope: this
});
}
});
Rally.launchApp('BVApp', {
name: 'Business Values App'
});
});
感謝您的提示 - 不幸的是,這似乎沒有改變任何事實的記錄。 另外我想知道如何將RowEditing插件註釋掉,因爲如果我不保留它,我不能編輯該行,或者我該怎麼辦? – 4jas