1

我正在尝试为 Rally 创建一个新应用程序,而且我对 Rally SDK 和 JavaScript 都是新手。我找到了有关构建您的第一个 Rally 应用程序的教程,并尝试从那里开始。但是,在执行示例时出现错误。

Uncaught TypeError: Cannot call method 'refresh' of undefined 

起初我以为我做错了什么,但最终我复制并粘贴了整个示例应用程序,却发现示例项目也发生了这种情况。

任何能指出我成功调试的正确方向的东西都将不胜感激!

App.js我正在使用的全部内容(来自示例)是这样的:

Ext.define('CustomApp', {
  extend: 'Rally.app.App',
  componentCls: 'app',
  items: { html: '<a href="https://help.rallydev.com/apps/2.0rc2/doc/">App SDK 2.0rc2 Docs</a>' },
  launch: function () {
    this.iterationCombobox = this.add({
      xtype: 'rallyiterationcombobox',
      listeners: {
        change: this._onIterationComboboxChanged,
        ready: this._onIterationComboboxLoad,
        scope: this
      }
    });
  },

  _onIterationComboboxLoad: function () {
    var addNewConfig = {
      xtype: 'rallyaddnew',
      recordTypes: ['User Story', 'Defect'],
      ignoredRequiredFields: ['Name', 'ScheduleState', 'Project'],
      showAddWithDetails: false,
      listeners: {
        beforecreate: this._onBeforeCreate,
        scope: this
      }
    };

    this.addNew = this.add(addNewConfig);

    var cardBoardConfig = {
      xtype: 'rallycardboard',
      types: ['Defect', 'User Story'],
      attribute: 'ScheduleState',
      storeConfig: {
        filters: [this.iterationCombobox.getQueryFromSelected()]
      }
    };
    this.cardBoard = this.add(cardBoardConfig);
  },

  _onBeforeCreate: function (addNewComponent, record) {
    record.set('Iteration', this.iterationCombobox.getValue());
  },

  _onIterationComboboxChanged: function () {
    var config = {
      storeConfig: {
        filters: [this.iterationCombobox.getQueryFromSelected()]
      }
    };

    this.cardBoard.refresh(config);
  }
});
4

1 回答 1

1

试试这个代码。此 git hub repo中提供了源代码。

Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'iteration',
    onScopeChange: function(scope) {
        this._iteration = scope.record.get('_ref');
        if (!this.down('#addNew')) {
         var addNewConfig = {
            xtype: 'rallyaddnew',
            itemId: 'addNew',
            recordTypes: ['User Story', 'Defect'],
            ignoredRequiredFields: ['Name', 'ScheduleState', 'Project'],
            showAddWithDetails: false,
            listeners: {
                beforecreate: this._onBeforeCreate,
                scope: this
            }
        }; 
    }


        this.addNew = this.add(addNewConfig);
        if(!this.board) {
             this.board = this.add({
                xtype: 'rallycardboard',
                storeConfig: {
                    filters: [scope.getQueryFilter()]
                }
            });
        } else {
            this.board.refresh({
                storeConfig: {
                    filters: [scope.getQueryFilter()]
                }
            });
        }
        this.iteration = scope.getRecord();
    },

    _onBeforeCreate: function(addNewComponent, record) {
    record.set('Iteration', this._iteration);
}
});
于 2014-03-03T22:05:51.947 回答