2012-04-03 82 views
1

我想先說我已經閱讀Rally Kanban - hiding Epic Stories,但是我仍然在實施基於估算板應用程序的過濾器過程的過濾器時遇到問題。目前我正在嘗試爲我的紙板的查詢對象添加一個項目過濾器。查詢對象調用this._getItems以返回要過濾的項目數組。據我可以告訴查詢調用該函數,加載一秒鐘或兩秒鐘,然後顯示沒有結果。歡迎任何意見,建議或替代解決方案。從看板董事會過濾史詩

這裏是我的代碼

$that._redisplayBoard = function() { 


      that._getAndStorePrefData(displayBoard); 

      this._getItems = function(callback) { 

      //Build types based on checkbox selections 
      var queries = []; 

        queries.push({key:"HierarchicalRequirement", 
         type: "HierarchicalRequirement", 
         fetch: "Name,FormattedID,Owner,ObjectID,Rank,PlanEstimate,Children,Ready,Blocked", 
         order: "Rank" 

        }); 



      function bucketItems(results) { 
       var items = []; 

       rally.forEach(queries, function(query) { 
        if (results[query.key]) { 
         rally.forEach(results[query.key], function(item) { 
          //exclude epic stories since estimates cannot be altered 
          if ((item._type !== 'HierarchicalRequirement') || 
            (item._type === 'HierarchicalRequirement' && item.Children.length === 0)) { 
           items = items.concat(item); 

          } 
         }); 
     } 
       }); 


       callback(items); 
       } 

       rallyDataSource.findAll(queries, bucketItems); 

      }; 

      function displayBoard() { 

       artifactTypes = []; 



       var cardboardConfig = { 

        types: [], 

        items: that._getItems, 

        attribute: kanbanField, 

        sortAscending: true, 

        maxCardsPerColumn: 200, 

        order: "Rank", 

        cardRenderer: KanbanCardRenderer, 

        cardOptions: { 

         showTaskCompletion: showTaskCompletion, 

         showAgeAfter: showAgeAfter 

        }, 

        columnRenderer: KanbanColumnRenderer, 

        columns: columns, 

        fetch: "Name,FormattedID,Owner,ObjectID,Rank,Ready,Blocked,LastUpdateDate,Tags,State,Priority,StoryType,Children" 

       }; 



       if (showTaskCompletion) { 

        cardboardConfig.fetch += ",Tasks"; 

       } 



       if (hideLastColumnIfReleased) { 

        cardboardConfig.query = new rally.sdk.util.Query("Release = null").or(kanbanField + " != " + '"' + lastState + '"'); 

       } 



       if (filterByTagsDropdown && filterByTagsDropdown.getDisplayedValue()) { 

        cardboardConfig.cardOptions.filterBy = { field: FILTER_FIELD, value: filterByTagsDropdown.getDisplayedValue() }; 

       } 



       cardboardConfig.types.push("HierarchicalRequirement"); 



       if (cardboard) { 

        cardboard.destroy(); 

       } 



       artifactTypes = cardboardConfig.types; 






       cardboard = new rally.sdk.ui.CardBoard(cardboardConfig, rallyDataSource); 




       cardboard.addEventListener("preUpdate", that._onBeforeItemUpdated); 
       cardboard.addEventListener("onDataRetrieved", function(cardboard,args){ console.log(args.items); }); 

       cardboard.display("kanbanBoard"); 

      } 

     }; 


     that.display = function(element) { 



      //Build app layout 

      this._createLayout(element); 



      //Redisplay the board 

      this._redisplayBoard(); 

     }; 

    }; 

回答

0

當cardboard.setItems(filteredItems)被調用時,Mark的回答引起了一個模糊的崩潰。但是,由於過濾代碼實際上是在處理實際引用,因此實際上並不需要setItems()方法。我把它拉出來,現在它過濾得當。

+0

好抓!我編輯了我的答案以反映你的發現。 – 2012-04-05 06:18:29

+0

我不確定是否正確的堆棧溢出禮節將其標記爲答案,但我沒有足夠的代表upvote,所以你去了。 – user1145893 2012-04-05 12:16:44

0

不知道這是你的問題,但你的紙板的配置不設置「查詢」字段。 fetch是要檢索的所有數據的類型,如果要過濾它,請向配置對象添加「query:」值。 喜歡的東西:

 var cardboardConfig = { 
     types: ["PortfolioItem", "HierarchicalRequirement", "Feature"], 
     attribute: dropdownAttribute, 
     fetch:"Name,FormattedID,Owner,ObjectID,ClassofService", 
     query : fullQuery, 
     cardRenderer: PriorityCardRenderer 
    }; 

在哪裏可以使用拉力查詢對象來構建fullQuery。您可以通過在SDK中搜索來找到它。希望這可能有所幫助。

+0

應該將fullQuery放在引號中嗎?當我按原樣添加查詢時,看板無法顯示。當我添加引號時,它會加載,但仍然沒有響應。 – user1145893 2012-04-04 12:29:20

1

Charles'一絲Rally Kanban - hiding Epic Stories

以下是我走近這個以下查爾斯的提示造勢目錄看板。首先,修改cardboardConfig內取語句,以便它包括兒童的收集,正是如此:

 fetch: "Name,FormattedID,Children,Owner,ObjectID,Rank,Ready,Blocked,LastUpdateDate,Tags,State" 

接下來,在此聲明之間:

 cardboard.addEventListener("preUpdate", that._onBeforeItemUpdated); 

而且這樣的說法:

 cardboard.display("kanbanBoard"); 

添加以下事件偵聽器和回調:

cardboard.addEventListener("onDataRetrieved", 
     function(cardboard, args){ 
      // Grab items hash 
      filteredItems = args.items; 

      // loop through hash keys (states) 
      for (var key in filteredItems) { 

       // Grab the workproducts objects (Stories, defects)     
       workproducts = filteredItems[key]; 
       // Array to hold filtered results, childless work products 
       childlessWorkProducts = new Array(); 
       // loop through 'em and filter for the childless 
       for (i=0;i<workproducts.length;i++) { 
        thisWorkProduct = workproducts[i];      
        // Check first if it's a User Story, since Defects don't have children 
        if (thisWorkProduct._type == "HierarchicalRequirement") { 
         if (thisWorkProduct.Children.length === 0) { 
          childlessWorkProducts.push(thisWorkProduct); 
         } 
        } else { 
         // If it's a Defect, it has no children so push it 
         childlessWorkProducts.push(thisWorkProduct); 
        } 
       } 
       filteredItems[key] = childlessWorkProducts; 
      } 
      // un-necessary call to cardboard.setItems() was here - removed 
     } 
    ); 

此回調應該只篩選葉節點項目。

+0

非常感謝你,這開始讓我瘋狂! – user1145893 2012-04-05 12:15:28