使用自定义“下拉列表”字段在网格中设置值

时间:2017-02-16 14:47:11

标签: rally

我正在尝试使用Rally 2.1 SDK在网格中设置自定义数据字段(c_wsjf)。我有一个自定义下拉列表,我想检查(c_TimeCrticalitySizing)的值。

我在我的Rally工作区中创建了c_TimeCrticalitySizing作为功能卡字段,其中包含不同的字符串值(例如“No decay”)。每个下拉列表值都会将自定义字段设置为不同的整数。当我尝试在Rally中运行应用程序时出现此错误:

“未捕获的TypeError:无法读取未定义的属性'isModel'(...)”

我认为下拉列表值可能不是字符串。

我如何检查下拉列表值的类型是什么?

如何重写此代码以正确检查下拉列表的值,以便将自定义字段设置为不同的整数?

这是我的完整应用程序的代码块。我还在尝试连接搜索栏,所以现在我直接从_onDataLoaded()功能调用launch()

// START OF APP CODE
Ext.define('CustomApp', {
  extend: 'Rally.app.App',
  componentCls: 'app',

  featureStore: undefined,
  featureGrid: undefined,

  items: [      // pre-define the general layout of the app; the skeleton (ie. header, content, footer)
    {
      xtype: 'container', // this container lets us control the layout of the pulldowns; they'll be added below
      itemId: 'widget-container',
      layout: {
              type: 'hbox',           // 'horizontal' layout
              align: 'stretch'
          }
    }
  ],

  // Entry point of the app
  launch: function() {
    var me = this;

    me._onDataLoaded();
  },

  _loadSearchBar: function() {
    console.log('in loadsearchbar');

    var me = this;

    var searchComboBox = Ext.create('Rally.ui.combobox.SearchComboBox', {
      itemId: 'search-combobox',
      storeConfig: {
        model: 'PortfolioItem/Feature'
      },
      listeners: {
        ready: me._onDataLoaded,
        select: me._onDataLoaded,
        scope: me
      }

    });

    // using 'me' here would add the combo box to the app, not the widget container
    this.down('#widget-container').add(searchComboBox); // add the search field to the widget container <this>
  },

  // If adding more filters to the grid later, add them here
  _getFilters: function(searchValue){
    var searchFilter = Ext.create('Rally.data.wsapi.Filter', {
      property: 'Search',
      operation: '=',
      value: searchValue
    });

    return searchFilter;
  },

  // Sets values once data from store is retrieved
  _onDataLoaded: function() {
    console.log('in ondataloaded');

    var me = this;

    // look up what the user input was from the search box
    console.log("combobox: ", this.down('#search-combobox'));
    //var typedSearch = this.down('#search-combobox').getRecord().get('_ref');

    // search filter to apply
    //var myFilters = this._getFilters(typedSearch);

    // if the store exists, load new data
    if (me.featureStore) {
      //me.featureStore.setFilter(myFilters);
      me.featureStore.load();
    }
    // if not, create it
    else {
      me.featureStore = Ext.create('Rally.data.wsapi.Store', {
        model: 'PortfolioItem/Feature',
        autoLoad: true,
        listeners: {
          load:  me._createGrid,
          scope: me
        },
        fetch: ['FormattedID', 'Name', 'TimeCriticality',
        'RROEValue', 'UserBusinessValue', 'JobSize', 'c_TimeCriticalitySizing']
      });
    }

  },

  // create a grid with a custom store
  _createGrid: function(store, data){
    var me = this;

    var records = _.map(data, function(record) {
      //Calculations, etc.
      console.log(record.get('c_TimeCriticalitySizing'));
      var timecritsize = record.get('c_TimeCriticalitySizing');
      //console.log(typeof timecritsize);
      var mystr = "No decay";

      var jobsize = record.get('JobSize');
      var rroe = record.get('RROEValue');
      var userval = record.get('UserBusinessValue');
      var timecrit = record.get('TimeCriticality');

      // Check that demoniator is not 0
      if ( record.get('JobSize') > 0){
        if (timecritsize === mystr){
          var priorityScore = (timecrit + userval + rroe) / jobsize;

          return Ext.apply({
            c_wsjf: Math.round(priorityScore * 10) / 10
          }, record.getData());
        }

      }
      else{
        return Ext.apply({
          c_wsjf: 0
        }, record.getData());
      }
    });

    // Add the grid
    me.add({
      xtype: 'rallygrid',
      showPagingToolbar: true,
      showRowActionsColumn: true,
      enableEditing: true,
      store: Ext.create('Rally.data.custom.Store', {
        data: records
      }),

      // Configure each column
      columnCfgs: [
        {
          xtype: 'templatecolumn',
          text: 'ID',
          dataIndex: 'FormattedID',
          width: 100,
          tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
        },
        {
          text: 'WSJF Score',
          dataIndex: 'c_wsjf',
          width: 150
        },
        {
          text: 'Name',
          dataIndex: 'Name',
          flex: 1,
          width: 100
        }
      ]
    });
  }

});
// END OF APP CODE

在我添加if (timecritsize === mystr)条件之前,该应用很有效。 我还使用console.log()检查我是否将timecritsize的所有值都设置为“No decay”

0 个答案:

没有答案