2015-02-06 55 views
1

我有兩個工作區 當我在一個工作區加載我的應用程序時,它與過濾器一起工作,但是當我使用相同的代碼時它不起作用。 然後我嘗試評論過濾器,然後它給了我整個記錄。不能圖什麼區別, 我使用拉力sdk2.0rc3下面 是我的代碼片段過濾器無法在特定的工作區拉力賽

this._startDate2014-09-10

this._endDate2015-03-03

,當我打印操作它提供虛假

and iterations = []

@nickm幫我

  _onDataLoaded: function() { 
       console.log("this.getContext().getProject()._ref", this.getContext().getProject()._ref); 
       console.log("this._startDate", this._startDate); 
       console.log("this._endDate", this._endDate); 
       var project_oid = this.getContext().getProject()._ref; 

       var startDateFilter = Ext.create('Rally.data.QueryFilter', { 
        property: 'StartDate', 
        operator: '>', 
        value: this._startDate 
       }); 
       startDateFilter = startDateFilter.and({ 
        property: 'StartDate', 
        operator: '<', 
        value: this._endDate 
       }); 
       startDateFilter = startDateFilter.and({ 
        property: 'StartDate', 
        operator: '!=', 
        value: null 
       }); 
       var endDateFilter = Ext.create('Rally.data.QueryFilter', { 
        property: 'EndDate', 
        operator: '<', 
        value: this._endDate 
       }); 
       endDateFilter = endDateFilter.and({ 
        property: 'EndDate', 
        operator: '>', 
        value: this._startDate 
       }); 
       endDateFilter = endDateFilter.and({ 
        property: 'EndDate', 
        operator: '!=', 
        value: null 
       }); 
       var filter = startDateFilter.or(endDateFilter); 
       //filter.toString(); 
       Ext.create('Rally.data.WsapiDataStore', { 
        model: 'Iteration', 
        limit: Infinity, 
        context: { 
         project: project_oid, 
         projectScopeDown: true, 
         projectScopeUp: false 
        },       
        fetch: ['Name','Project', 'StartDate', 'EndDate', 'Parent', 'Children'], 
        autoLoad: true, 
        filters: [ 
         filter 
        ], 
        listeners: { 
         load: this._loadGrid, 
         scope:this 
        }     
       }, this); 
      }, 
      _loadGrid: function(store, iterations, operation) { 
       console.log("hi there", operation); 

回答

1

我的第一個猜測是,如果相同的代碼工作在一個工作空間和其他工作區不起作用,而罪魁禍首是基於日期值過濾,檢查你的工作區有不同日期格式。例如是這樣的:

enter image description here

或這樣的:

enter image description here

但我在工作空間中測試 '2015年2月6日' 值,該值使用毫米/ dd/yyyy格式和有效。

在任何情況下,如果它在一個工作區中工作,並且在另一個機會中不起作用,這不是代碼問題,而是數據問題。也許在第二個工作空間中,相同的查詢返回0個結果。另外,根據代碼中使用的日期的含義,可以避免硬編碼日期。例如,要獲得當前迭代試試這個:

var today = new Date().toISOString(); 
filters: [ 
       { 
        property: 'StartDate', 
        operator: '<=', 
        value: today 
       }, 
       { 
        property: 'EndDate', 
        operator: '>=', 
        value: today 
       } 
      ] 
+0

感謝尼克,是的,我在我的日期使用了這個'toISOString()',它工作。非常感謝 – Sontya 2015-02-09 07:04:26