2014-09-26 71 views
2

我有一个状态组合框,成功过滤在拉力赛。下面的代码工作。我想添加一个增强功能,并将组合框的默认设置为“进行中”。我添加了defaultValue,但它没有效果。谢谢你的帮助。拉力赛设置组合框的默认值

Rally.onReady(function() { 
     Ext.define('Rally.example.CustomStoreGrid', { 
      extend: 'Rally.app.App', 
      componentCls: 'app', 

      launch: function() { 
       Ext.create('Rally.data.wsapi.Store', { 
        model: 'defect', 
        autoLoad: true, 
        limit: 1000, 
        pageSize: 1000, 
        listeners: { 
         load: this._onDataLoaded, 
         scope: this 
        }, 
        fetch: ['FormattedID', 'Name', 'Severity', 'State', 'InProgressDate', 'c_PlannedDeliveryVersion'] 
       }); 
      }, 
      _onSelect: function() { 
       var grid = this.down('rallygrid'), store = grid.getStore(); 
       store.clearFilter(true); 

       store.filter(this._getStateFilter()); 
      }, 
      _getStateFilter: function() { 
       return { 
        property: 'State', 
        operator: '=', 
        defaultValue: 'In Progress', 

        value: this.down('#priorityComboBox').getValue() 

       }; 
      }, 
      _onDataLoaded: function(store, data) { 
       var records = _.map(data, function(record) { 
        //Perform custom actions with the data here 
        //Calculations, etc. 
        return Ext.apply({ 
         // Age: Math.round(((new Date() - record.get('InProgressDate'))/86400000) * 10)/10; 
        }, record.getData()); 
       }); 
       this.add({ 
        xtype: 'rallyfieldvaluecombobox', 
        itemId: 'priorityComboBox', 
        fieldLabel: 'Filter by State:', 
        model: 'defect', 

        // multiSelect: true, 
        field: 'State', 

        listeners: { 
         select: this._onSelect, 
         // ready: this._onLoad, 
         scope: this 
        } 
       }); 
       this.add({ 
        xtype: 'rallygrid', 
        showPagingToolbar: false, 
        showRowActionsColumn: false, 
        editable: false, 
        store: Ext.create('Rally.data.custom.Store', { 
         limit: 1000, 
         pageSize: 1000, 
         data: records 
        }), 
        columnCfgs: [ 
         { 
          xtype: 'templatecolumn', 
          text: 'ID', 
          dataIndex: 'FormattedID', 
          width: 100, 
          tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate') 
         }, 
         { 
          text: 'Name', 
          dataIndex: 'Name', 
          flex: 1 
         }, 
         { 
          text: 'Severity', 
          dataIndex: 'Severity' 
         }, 
         { 
          text: 'State', 
          dataIndex: 'State' 

         }, 
         { 
          text: 'Planned Delivery Version', 
          dataIndex: 'c_PlannedDeliveryVersion', 
          flex: 0.25 
         }, 
         { 
          text: 'In Progress Date', 
          dataIndex: 'InProgressDate', 
          xtype: 'datecolumn', 
          format:'Y-m-d' 
         }, 
         { 
          text: 'Age', 
          dataIndex: 'InProgressDate' 
          , 
          renderer: function(value) { 
           return Math.round(((new Date() - value)/86400000) * 10)/10; 
          } 
         } 
        ] 
       }); 
      } 
     }); 


     Rally.launchApp('Rally.example.CustomStoreGrid', { 
      name: 'Custom Store Grid Example' 
     }); 
    }); 

回答

1

使用value配置属性设置为默认值:

Ext.define('CustomApp', { 
    extend: 'Rally.app.App', 
    componentCls: 'app', 
    items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc3/doc/">App SDK 2.0rc3 Docs</a>'}, 
    launch: function() { 
     this.add({ 
       xtype: 'rallyfieldvaluecombobox', 
       model: 'UserStory', 
       field: 'ScheduleState', 
       value: 'In-Progress' 
      }); 
    } 
});