集計されたフィールドを編集し、その集計のさまざまなコンポーネントの計算結果を別のフィールドに保存できるようにすることを目的とした私のアプリを続けます...
UserStory モデルの拡張機能を使用してフィールドを適切に取得できるようになりましたが、変更を保存できません。Ext.grid.plugin.RowEditing の編集イベントで何が行われたかを確認しようとしていますが、それに到達すると、e.store.data.items[rowIdx].data にすべての期待値、ダーティ フラグ、編集フラグが含まれていることに気付きました。は false ですが、 e.store.data.items[rowIdx].raw はそれを反映していません (変更されていない Rally の元の値が含まれています) - 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'
});
});