2014-05-18 16 views
1

我正尝试创建一个在网格视图中显示数据的自定义拉力赛应用程序。在另一个问题Rally SDK App Using Grid with collapsible tree of children storiesnickm张贴一些示例代码如何在自定义网格中以拉力赛网格的方式显示ScheduleState和阻止列

Ext.define('CustomApp', { 
extend: 'Rally.app.App', 
componentCls: 'app', 
launch: function() { 
    var today = new Date().toISOString(); 
    Ext.create('Rally.data.wsapi.Store', { 
      model: 'UserStory', 
      fetch: ['ObjectID', 'FormattedID', 'Name', 'ScheduleState', 'Feature'], 
      autoLoad: true, 
      filters: [ 
       { 
        property: 'Iteration.StartDate', 
        operator: '<=', 
        value: today 
       }, 
       { 
        property: 'Iteration.EndDate', 
        operator: '>=', 
        value: today 
       }, 
       { 
        property: 'Feature', 
        operator: '!=', 
        value: null 
       } 
      ], 
      listeners: { 
       load: this._onDataLoaded, 
       scope: this 
      } 
      }); 
}, 
_onDataLoaded: function(store, records){ 
    var that = this; 
    var promises = []; 
    _.each(records, function(story) { 
     promises.push(that._getFeature(story, that)); 
    }); 

    Deft.Promise.all(promises).then({ 
     success: function(results) { 
      that._stories = results; 
      that._makeGrid(); 
     } 
    }); 
}, 

_getFeature: function(story, scope) { 
    var deferred = Ext.create('Deft.Deferred'); 
    var that = scope; 
     var featureOid = story.get('Feature').ObjectID; 
     Rally.data.ModelFactory.getModel({ 
     type: 'PortfolioItem/Feature', 
     scope: this, 
     success: function(model, operation) { 
      fetch: ['State'], 
      model.load(featureOid, { 
       scope: this, 
       success: function(record, operation) { 
        var featureState = record.get('State')._refObjectName; 
        var storyRef = story.get('_ref'); 
        var storyOid = story.get('ObjectID'); 
        var storyFid = story.get('FormattedID'); 
        var storyName = story.get('Name'); 
        var storyState = story.get('ScheduleState'); 
        var feature = story.get('Feature'); 

        result = { 
           "_ref"   : storyRef, 
           "ObjectID"  : storyOid, 
           "FormattedID" : storyFid, 
           "Name"   : storyName, 
           "ScheduleState" : storyState, 
           "Feature"  : feature, 
           "FeatureState" : featureState, 
           "FeatureID"  : featureOid 
          }; 
        deferred.resolve(result);  
       } 
      }); 
     } 
    }); 
    return deferred; 
}, 

_makeGrid: function() { 
    var that = this; 

    if (that._grid) { 
     that._grid.destroy(); 
    } 

    var gridStore = Ext.create('Rally.data.custom.Store', { 
     data: that._stories, 
     groupField: 'FeatureID', 
     pageSize: 1000, 
    }); 

    that._grid = Ext.create('Rally.ui.grid.Grid', { 
     itemId: 'storyGrid', 
     store: gridStore, 
     features: [{ftype:'grouping'}], 
     columnCfgs: [ 
      { 
       text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn', 
       tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate') 
      }, 

      { 
       text: 'Name', dataIndex: 'Name', 
      }, 
      { 
       text: 'ScheduleState', dataIndex: 'ScheduleState', 
      }, 
      { 
       text: 'Feature', dataIndex: 'Feature', 
       renderer: function(val, meta, record) { 
        return '<a href="https://rally1.rallydev.com/#/detail/portfolioitem/feature/' + record.get('Feature').ObjectID + '" target="_blank">' + record.get('Feature').FormattedID + '</a>'; 
       } 
      }, 
      { 
       text: 'Feature State', dataIndex: 'FeatureState', 
      } 
     ] 
    }); 

    that.add(that._grid); 
    that._grid.reconfigure(gridStore); 
} 
}); 

我想显示ScheduleState和阻止列同样的方式,拉力赛窗格显示它们(如图形表示)。我一直试图弄清楚如何使用我的columnCfgs以下使用TemplateColumn中的xtype阻止:

{ text: 'State', dataIndex: 'ScheduleState', xtype: 'templatecolumn', 
       tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate') } 

这种失败并导致在SDK-debug.js一个JS错误:

Uncaught TypeError: Cannot read property 'getAllowedValueStore' of undefined sdk-debug.js:190539 Ext.define.loadStates

我在Blocked列中遇到了不同的错误,但我一直无法弄清楚如何让它显示为红色的阻止图标。

This is what I'm trying to achieve

回答

0

有了一些调整我预计这将在AppSDK2的下一个版本的工作,但现在的ScheduleState的渲染和封锁只会用数据WSAPI店工作。使用

tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate')

是不够的。自定义商店无法访问有效状态。

UPDATE

ScheduleState的渲染和当前x版本AppSDK2作为本次更新日期受阻作品5/22

<script type="text/javascript" src="/apps/x/sdk.js"></script> 

此修复程序将最终使公司的方式AppSDK2的下一个正式版本,但现在您可以将其与AppSDK2的x版本一起使用。

警告x AppSDK的版本从来不稳定 - 不断变化。

查看完整的code example here

x版本AppSDK你可以这样做:

enableBlockedReasonPopover: false 

{ 
    text: 'ScheduleState', dataIndex: 'ScheduleState', xtype: 'templatecolumn', 
     tpl: Ext.create('Rally.ui.renderer.template.ScheduleStateTemplate', 
      { 
       states: ['Defined', 'In-Progress', 'Completed', 'Accepted'], 
       field: {name: 'ScheduleState' } 
      }) 
}, 
{ 
    text: 'Blocked', dataIndex: 'Blocked', xtype: 'templatecolumn', 
     tpl: Ext.create('Rally.ui.renderer.template.BlockedTemplate') 
} 

而且,就目前而言,在网格配置此设置为false

相关问题