想要根据我的网格集会上新编辑的值更新其他列字段值

Want to update other column field values based on the new edited value on my grid rally

我有一个应用程序显示 grid

当我编辑一个字段(薪水)时,我想根据 salary 的新编辑值更新其他列字段值,例如 cost。 因此 cost 将计算为 salary 除以编号。开发人员(计数) 我尝试这样做,但无法设置值。

有什么建议

下面是我的代码

            _getSpan: function(val) {
                return val;
            },
            _draw_grid: function(newHash, committedData) {
                acceptedPoints = {};
                Ext.Array.each(committedData, function(cData){
                    if ( ! acceptedPoints[cData.ProjectName] ) { acceptedPoints[cData.ProjectName] = 0; }
                    acceptedPoints[cData.ProjectName] = cData.Accept;
                });
                summaryHash = {};
                _.each(projects, function(team) {
                    if (!summaryHash[team] && newHash[team]) {
                        summaryHash[team] = {
                            Name: team,
                            Count: newHash[team].length,
                            Days: 10,
                            Points: acceptedPoints[team],
                            Salary: "200,000",
                            Cost: 200000/newHash[team].length, 
                            ManDays: 0
                        };
                        if (acceptedPoints[team] > 0) {
                            summaryHash[team].ManDays = (10/acceptedPoints[team]) * newHash[team].length;
                        }
                    };
                });
                records = [];
                Ext.Object.each(summaryHash, function(key, value) {     
                    if (newHash[key]) {
                        records.push(value);
                    }   
                });
                this.records = records;
                var cfgsValues = [];
                var self = this;
                cfgsValues.push({text: 'Teams', style:"background-color: #D2EBC8", dataIndex: 'Name', width: 170, renderer: function(value, meta_data, record, row, col) {
                    return value;
                }});                    
                cfgsValues.push({text: '# Developers', style:"background-color: #D2EBC8", dataIndex: 'Count', width: 70, renderer: function(value, meta_data, record, row, col) {
                    self.Count = value;
                    return value;
                }});
                cfgsValues.push({text: '# Points', style:"background-color: #D2EBC8", dataIndex: 'Points', width: 70, renderer: function(value, meta_data, record, row, col) {
                    return value;
                }});                    
                cfgsValues.push({text: '# Days in Sprint', style:"background-color: #D2EBC8", dataIndex: 'Days', width: 70, renderer: function(value, meta_data, record, row, col) {
                    return value;
                }});
                cfgsValues.push(
                    {text: '# Average Salary Cost per Sprint', style:"background-color: #D2EBC8", dataIndex: 'Salary', width: 100, renderer: function(value, meta_data, record, row, col) {
                        self.value = value;
                        return "$" +value;
                    }, 
                    editor: {
                        xtype: 'textfield', // this assumes that salary is a number; if not, set to 'textfield'
                        listeners: {
                            click: {
                                element: 'el', //bind to the underlying el property on the panel
                                fn: function(){ 
                                    self.cost = self.value/self.Count;
                                    console.log('click el', self.value, self); 
                                    self._getSpan(self.cost);
                                }
                            }
                        }
                    }
                });                     
                cfgsValues.push({text: '# Cost of 1 Story Point', style:"background-color: #D2EBC8", dataIndex: 'Cost', width: 100, renderer: function(value, meta_data, record, row, col) {
                    self.cost = value;
                    //return "$"+ Ext.Number.toFixed(value, 2);
                    return self._getSpan(record.raw.Cost);
                }});
                cfgsValues.push({text: '# man-days need per 1 Story Point', style:"background-color: #D2EBC8", dataIndex: 'ManDays', width: 100, renderer: function(value, meta_data, record, row, col) {
                    self.man_days = value;
                    return Ext.Number.toFixed(value, 2);
                }});                    
                this.setLoading(false);
                self.add({
                    xtype: 'rallygrid',
                    bodyBorder: 1,
                    id: 'mychart',
                    showPagingToolbar: false,
                    showRowActionsColumn: false,
                    enableEditing:true,
                    editable: true,
                    selType: 'cellmodel',
                    plugins: [
                        Ext.create('Ext.grid.plugin.CellEditing', {
                            clicksToEdit: 2
                        })
                    ],                      
                    store: Ext.create('Rally.data.custom.Store', {
                        data: records
                    }),
                    columnCfgs: cfgsValues
                });             
            }               

嘿,找到方法了

我只是在开始时保留了 Cost0

summaryHash[team] = {
    Name: team,
    Count: newHash[team].length,
    Days: 10,
    Points: acceptedPoints[team],
    Salary: "200000",
    Cost: 0, 
    ManDays: 0
};

然后使我的 Salary 列可编辑

cfgsValues.push(
    {text: '# Average Salary Cost per Sprint', style:"background-color: #D2EBC8", dataIndex: 'Salary', width: 100, renderer: function(value, meta_data, record, row, col) {
        return "$" +value;
    }, 
    editor: {
        xtype: 'textfield', // this assumes that salary is a number; if not, set to 'textfield'
    }
}); 

现在,每当我编辑 Salary 值时,它都会更改 Cost

cfgsValues.push({text: '# Cost of 1 Story Point', style:"background-color: #D2EBC8", dataIndex: 'Cost', width: 100, renderer: function(value, meta_data, record, row, col) {
    return Ext.Number.toFixed(record.get('Salary')/record.get('Count'), 2);
}});