Javascript 从Rally中获取特定标记,以便计算另一个字段中的值
我对Rally development非常陌生,所以我的问题可能听起来很愚蠢(但从Rally的帮助或以前的帖子中找不到如何做到这一点):) 我从rally freeform网格示例开始—我的目的是实现一个业务价值计算器:我用一个5位数的数字填充分数字段,其中每个数字都是1-5范围内的分数。 然后我计算一个业务值作为计算的结果,其中每个数字都由一个预设的权重加权。 我可以根据业务价值对我的故事进行排序,以帮助我确定待办事项的优先级:这是第一步,而且很有效 现在我想做的是使我的自由形式网格可编辑:我提取我的每一个数字作为一个单独的列,但这些列只显示。我怎样才能把它们变成可编辑的东西?当然,我想做的是根据每个自定义列中输入的值更新回score字段 下面是一个例子: 我有一个得分为“15254”的记录,这意味着商业价值标准1分为1分(满分5分),商业价值标准2分为5分(满分5分),依此类推。。。 最后我的业务价值计算为“1*1+5*2+2*3+5*4+4*5=57”。 到目前为止,这是有效的部分。 现在让我们假设我发现第三个标准的分数不应该是2,而是3,我希望能够编辑相应列中的值,并将我的分数字段更新为“15354”,将我的业务值显示为60而不是57 这是我当前的代码,如果您能帮助我将网格转换为可编辑的内容,我将不胜感激:)Javascript 从Rally中获取特定标记,以便计算另一个字段中的值,javascript,rally,Javascript,Rally,我对Rally development非常陌生,所以我的问题可能听起来很愚蠢(但从Rally的帮助或以前的帖子中找不到如何做到这一点):) 我从rally freeform网格示例开始—我的目的是实现一个业务价值计算器:我用一个5位数的数字填充分数字段,其中每个数字都是1-5范围内的分数。 然后我计算一个业务值作为计算的结果,其中每个数字都由一个预设的权重加权。 我可以根据业务价值对我的故事进行排序,以帮助我确定待办事项的优先级:这是第一步,而且很有效 现在我想做的是使我的自由形式网格可编辑:我
onReady(函数(){
Ext.define('BVApp'{
扩展:“Rally.app.app”,
组件CLS:“应用程序”,
启动:函数(){
Ext.create('Rally.data.WsapiDataStore'{
模型:“用户故事”,
自动加载:对,
听众:{
加载:这个。加载后,
范围:本
}
});
},
_onDataLoaded:函数(存储、数据){
var记录=[];
var-li_评分;
var li_bv1、li_bv2、li_bv3、li_bv4、li_bv5、li_bvtotal;
变量权重=新数组(1,2,3,4,5);
Ext.Array.each(数据、函数(记录){
//让我们获取分数并计算业务价值。。。
li_score=记录。获取('score');
如果(李_分数){
li_bv1=li_分数.toString()子字符串(0,1);
li_bv2=li_分数.toString()子串(1,2);
li_bv3=li_分数.toString()子串(2,3);
li_bv4=li_分数.toString()子串(3,4);
li_bv5=li_分数.toString()子串(4,5);
li_bvtotal=
li_bv1*权重[0]+
li_bv2*重量[1]+
li_bv3*重量[2]+
li_bv4*重量[3]+
li_bv5*权重[4];
}
记录。推送({
FormattedID:record.get('FormattedID'),
ref:record.get(“u ref”),
Name:record.get('Name'),
Score:record.get('Score'),
Bv1:li_Bv1,
Bv2:li_Bv2,
Bv3:li_Bv3,
Bv4:li_Bv4,
Bv5:li_Bv5,
BvTotal:li_BvTotal
});
});
这个。添加({
xtype:“rallygrid”,
store:Ext.create('Rally.data.custom.store'{
数据:记录,
页面大小:5
}),
专栏CFGS:[
{
文本:“FormattedID”,数据索引:“FormattedID”
},
{
文本:“ref”,数据索引:“ref”
},
{
文本:“名称”,数据索引:“名称”,flex:1
},
{
文本:“分数”,数据索引:“分数”
},
{
文本:“BusVal 1”,数据索引:“Bv1”
},
{
文本:“BusVal 2”,数据索引:“Bv2”
},
{
文本:“BusVal 3”,数据索引:“Bv3”
},
{
文本:“BusVal 4”,数据索引:“Bv4”
},
{
文本:“BusVal 5”,数据索引:“Bv5”
},
{
文本:“BusVal Total”,数据索引:“BvTotal”
}
]
});
}
});
Rally.launchApp('BVApp'{
名称:“商业价值应用程序”
});
var exampleHtml='Business Values App'+
“自己的商业价值示例应用程序”+
'';
//默认应用程序视口使用布局:“适合”,
//所以我们需要在视口中插入一个容器
var viewport=Ext.ComponentQuery.query('viewport')[0];
var appComponent=viewport.items.getAt(0);
var viewportContainerItems=[{
html:examplethtml,
边界:0
}];
//暂时在示例中隐藏高级硬纸板实时预览
viewportContainerItems。
<!--Include SDK-->
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p2/sdk-debug.js"></script>
<!--App code-->
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('BVApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
autoLoad: true,
listeners: {
load: this._onDataLoaded,
scope: this
}
});
},
_onDataLoaded: function(store, data) {
var records = [];
var li_score;
var li_bv1, li_bv2, li_bv3, li_bv4, li_bv5, li_bvtotal;
var weights = new Array(1, 2, 3, 4, 5);
Ext.Array.each(data, function(record) {
//Let's fetch score and compute the business values...
li_score = record.get('Score');
if (li_score) {
li_bv1 = li_score.toString().substring(0,1);
li_bv2 = li_score.toString().substring(1,2);
li_bv3 = li_score.toString().substring(2,3);
li_bv4 = li_score.toString().substring(3,4);
li_bv5 = li_score.toString().substring(4,5);
li_bvtotal =
li_bv1*weights[0] +
li_bv2*weights[1] +
li_bv3*weights[2] +
li_bv4*weights[3] +
li_bv5*weights[4];
}
records.push({
FormattedID: record.get('FormattedID'),
ref: record.get('_ref'),
Name: record.get('Name'),
Score: record.get('Score'),
Bv1: li_bv1,
Bv2: li_bv2,
Bv3: li_bv3,
Bv4: li_bv4,
Bv5: li_bv5,
BvTotal: li_bvtotal
});
});
this.add({
xtype: 'rallygrid',
store: Ext.create('Rally.data.custom.Store', {
data: records,
pageSize: 5
}),
columnCfgs: [
{
text: 'FormattedID', dataIndex: 'FormattedID'
},
{
text: 'ref', dataIndex: 'ref'
},
{
text: 'Name', dataIndex: 'Name', flex: 1
},
{
text: 'Score', dataIndex: 'Score'
},
{
text: 'BusVal 1', dataIndex: 'Bv1'
},
{
text: 'BusVal 2', dataIndex: 'Bv2'
},
{
text: 'BusVal 3', dataIndex: 'Bv3'
},
{
text: 'BusVal 4', dataIndex: 'Bv4'
},
{
text: 'BusVal 5', dataIndex: 'Bv5'
},
{
text: 'BusVal Total', dataIndex: 'BvTotal'
}
]
});
}
});
Rally.launchApp('BVApp', {
name: 'Business Values App'
});
var exampleHtml = '<div id="example-intro"><h1>Business Values App</h1>' +
'<div>Own sample app for Business Values</div>' +
'</div>';
// Default app viewport uses layout: 'fit',
// so we need to insert a container into the viewport
var viewport = Ext.ComponentQuery.query('viewport')[0];
var appComponent = viewport.items.getAt(0);
var viewportContainerItems = [{
html: exampleHtml,
border: 0
}];
//hide advanced cardboard live previews in examples for now
viewportContainerItems.push({
xtype: 'container',
items: [appComponent]
});
viewport.remove(appComponent, false);
viewport.add({
xtype: 'container',
layout: 'vbox',
items: viewportContainerItems
});
});
</script>
<!--App styles-->
<style type="text/css">
.app {
/* Add app styles here */
}
</style>
Rally.data.ModelFactory.getModel({
type: 'user story',
success: function(model){
this.CustomModel = Ext.define('BVModel', {
extend: model,
fields: [
{name: 'Bv1'}
...
]
});
},
scope: this
});
this.add({
xtype: 'rallygrid',
model: this.CustomModel,
columnCfgs: [
{
text: 'FormattedID', dataIndex: 'FormattedID'
},
{
text: 'ref', dataIndex: 'ref'
},
{
text: 'Name', dataIndex: 'Name', flex: 1
},
{
text: 'Score', dataIndex: 'Score'
},
{
text: 'BusVal 1', dataIndex: 'Bv1'
},
{
text: 'BusVal 2', dataIndex: 'Bv2'
}
]
});