javascript - Extjs Store to Array 获取对象属性

标签 javascript rally

我正在开发一个 Rally 应用程序 我正在使用商店从投资组合/功能模块中提取数据。 这按预期工作。我想将 lisener 返回的内容转换为 arry 我面临的问题是数组只是重新调整对象,我需要对象属性中的数据。 数组的结果如下所示

[“F1870”,“25343 - 一些项目名称”,“”,对象,对象,2015 年 4 月 27 日星期一 02:00:00 GMT-0400(东部夏令时间)]

第一个对象值应该是 John Smith。 John Smith 坐在

对象

0: "F1870"

1: "25343 - 一些 "

2:“”

3:对象

_p: "0"_ref: "blah Balh"

_refObjectName:“约翰·史密斯”

_refObjectUUID: "blah blah"

_类型:

所有者[_refObjectName] 我需要得到什么,但我迷路了。

******编辑以添加更多细节**** 商店返回值如下所示

数据:对象

格式化ID:F1223

名称:某项目

描述:哇哇哇哇

所有者:对象 _p:

 _ref:

 _refObjectName: John Smith 

我需要数组返回

格式化ID:F1223

名称:某项目

描述:哇哇哇哇

所有者:约翰·史密斯

这是我目前的代码。

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function () {
        console.log("App Launched")   
   //App Calls the portfolio feature data store
   this._getfeaturedatastore();
    },
    //Get the portfolio feature data from Rally 
    _getfeaturedatastore: function(){   
       var getfeaturedata = Ext.create('Rally.data.wsapi.Store', {
    model: 'PortfolioItem/Feature',
    autoLoad: true,
   //Create Fillter for the Store 
     filters: [
        {
            property: 'State.Name',
        
            value: 'Story Definition',
        }
    ],
    listeners: {
        load: function(getfeaturedatastore, getfeaturedatadata, success) {
        console.log("Got Feature Data Woot",getfeaturedatastore, getfeaturedatadata, success)    
        this._displayFeatureCard(getfeaturedata);
        },
        
         scope: this
    },
    fetch: ['State', 'Name', 'Description', 'Owner', 'Parent','PlannedStartDate','FormattedID','Tags']
});
    },
    
    _displayFeatureCard: function(getfeaturedata){
        var MAX_NAME_LEN = 115;
        var name,i,theMarkup, description, owner, parent, plannedstartdate, formattedid;
    
          
    var data =[];
    getfeaturedata.each(function(record){
    var recordArray = [
        record.get("FormattedID"),
        record.get("Name"),
        record.get("Description"),
        record.get("Owner"),
        record.get("Parent"),
        record.get("PlannedStartDate")
        
        ];
        data.push(recordArray);
        console.log(recordArray)
    });
    

最佳答案

有关您有权访问哪些数据以及如何访问的线索,可通过 Web 服务文档访问(转到可通过右上角的头像访问的帮助链接)

保存在 Rally 数据库中的任何工件都可以返回给您:字符串、数字、对象或(对象的)集合。

在投资组合项的“所有者”的情况下,它是用户类型的对象。对象的内容描述所有者而不仅仅是提供名称。因为它是一个对象,所以您必须执行 record.get("Owner") 来获取对象,然后执行 record.get("Owner").Name 来获取所有者的名称。

FormattedID 以字符串形式返回,因此您只需执行 record.get("FormattedID") 即可获取文本。

关于javascript - Extjs Store to Array 获取对象属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30770359/

相关文章:

javascript - 我正在尝试让我的幻灯片放映更改图片 : pressing a button should change the displayed image to the button pressed

java - 如何检索与测试集关联的测试用例

java - 如何使用 Rally API 获取测试用例的结果?

java - Rally Rest Api-Android 应用程序-即使在导入所需的 jars 后也找不到类

java - 获取特定迭代下的所有任务(符合条件)?

python - Pyral deleteAttachment 从测试用例定义中删除附件不起作用

Javascript toLowerCase() 性能与变量创建

javascript - 为什么promise会这样解决呢? (使用通知回调)

javascript - 如何测量 JavaScript 中交互和 mousedown 事件之间的延迟?

javascript - Node : Asynchronous map for blocking jobs