Ext.define('MilestoneApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    
    launch: function() {
      this._loadMilestones();
      this._loadPortfolioItemTypes();
    },
   _loadMilestones: function() {
        Ext.create('Rally.data.WsapiDataStore', {
              autoLoad : true,
              limit : "Infinity",
              model : "Milestone",
              fetch : ["Name", "TargetDate"],
              listeners : {
                  scope : this,
                  load : function(store, data) {
                      this.milestones = store;
                      if(this.pfstore) this._onDataReady();
                  }
              }
          });
    },
    _loadPortfolioItemTypes: function() {
      //Usually PortfolioItem/Feature, but the name
      //could be changed in workspace so we need to 
      //dynamically determine lowest level
      
       var self = this;
       Ext.create('Rally.data.wsapi.Store', {
        model: 'TypeDefinition',
        autoLoad:true,
        filters: [{
          property: "TypePath",
          operator: "contains",
          value: "PortfolioItem/"
        }],
    
        listeners: {
            load: function(store, data, success) { 
              self._loadPortfolioItems(data[0].data.TypePath);
            }
        }
      });
    },
    _loadPortfolioItems: function(typePath) {  
        Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
            models: [typePath, "milestone"],
             root: {expanded: true},
            autoLoad: true,  
            enableHierarchy: true,
            context: null,
            filters: [
            {
              property: 'Milestones.ObjectID',
              operator: "!=",
              value: null
            }],
            listeners: {
                load: this._onDataLoaded,
                scope: this
            }
        }).then({
            success: this._onStoreBuilt.bind(this, typePath),
            scope: this
        });
    },
    _onDataLoaded: function(store, node, data) {
      this.pfstore = store;
      if(this.milestones) this._onDataReady();
      
                    
    },
    _onDataReady: function() {
      var self = this;
      _.map(this.pfstore.getTopLevelNodes(), function(record) {
        record.self.addField('DaysLate');
        record.self.addField('Milestone');
        record.self.addField('TargetDate');

        var milestone = self._findFirstMilestone(record.get("Milestones"));

        var plannedEndDate = record.get("PlannedEndDate");
        var targetDate = milestone.get("TargetDate");
        var targetDateString = moment(targetDate).format("MM/DD/YYYY");
        
        record.set("Milestone", milestone.data.Name);
        record.set("TargetDate", targetDateString);
        
        
        if( moment(plannedEndDate).diff(moment(targetDate)) > 0) {
          var daysLate = moment(plannedEndDate).diff(moment(targetDate), 'days') + 1;
          record.set("DaysLate", daysLate);
        } else {
          //record.remove();
        }
        
      });
    },
  
    _findFirstMilestone: function(pfmilestones) {
      var refs = _.pluck(pfmilestones._tagsNameArray, "_ref");
      
      var mdata = _.filter(this.milestones.data.items, function(milestone) { 
        return _.contains(refs, milestone.data._ref);
      });
      var sorted = _.sortBy(mdata, function(milestone) {
        return milestone.data.TargetDate;
      });
      return _.first(sorted);
    },
    _onStoreBuilt: function(modelName, store) {
        var modelNames = [modelName],
            context = this.getContext();
      
        store.model.addField({name: "Milestone"});
        store.model.addField({name: "TargetDate"});
        store.model.addField({name: "DaysLate"});
        var grid = this.add({
            xtype: 'rallygridboard',
            context: context,
            modelNames: modelNames,
            toggleState: 'grid',
            stateful: false,
            plugins: [
                {
                    ptype: 'rallygridboardfieldpicker',
                    headerPosition: 'right',
                    modelNames: modelNames,
                    stateful: true,
                    stateId: context.getScopedStateId('milestone-app')
                }
            ],
            gridConfig: {
                store: store,
                expandAllInColumnHeaderEnabled: true,
                columnCfgs: [
                    'Name',
                    'Project',
                    'Parent',
                    'Owner',
                    'PlannedEndDate',
                    'Milestones',
//                    {
//                      text: 'First Milestone',
//                      dataIndex: 'Milestone'
//                    },
                    {
                      text: 'First Target Date',
                      dataIndex: 'TargetDate'
                    },
                    {
                      text: 'Days Late',
                      dataIndex: 'DaysLate'
                    }
                    
                ],
                plugins: [
                {
                  ptype: "rallytreegridexpandedrowpersistence", 
                  enableExpandLoadingMask:false
                }]
                
            },
            height: this.getHeight()
        });
    }
  
});

@@ -1366,16 +1366,23 @@
 th) %7B  %0A
+      %0A
         
@@ -1470,61 +1470,11 @@
 Path
-, %22milestone%22
 %5D,%0A
-             root: %7Bexpanded: true%7D,%0A
     
@@ -1528,19 +1528,20 @@
 rarchy: 
-tru
+fals
 e,%0A     
@@ -2159,24 +2159,63 @@
 elf = this;%0A
+      //window.pfstore = this.pfstore;%0A
       _.map(
@@ -2472,17 +2472,43 @@
 nes%22));%0A
-%0A
+        if(milestone) %7B%0A%0A  
         
@@ -2558,32 +2558,34 @@
 Date%22);%0A        
+  
 var targetDate =
@@ -2606,32 +2606,34 @@
 (%22TargetDate%22);%0A
+  
         var targ
@@ -2688,29 +2688,23 @@
 YYYY%22);%0A
-  
+%0A
       
-%0A    
     reco
@@ -2745,32 +2745,34 @@
 .Name);%0A        
+  
 record.set(%22Targ
@@ -2799,24 +2799,17 @@
 tring);%0A
-        
+%0A
 %0A       
@@ -2809,23 +2809,16 @@
         
-%0A      
   if( mo
@@ -2866,24 +2866,26 @@
 te)) %3E 0) %7B%0A
+  
           va
@@ -2960,32 +2960,34 @@
  + 1;%0A          
+ 
+ 
 record.set(%22Days
@@ -3012,16 +3012,18 @@
         
+  
 %7D else %7B
@@ -3033,18 +3033,21 @@
         
+ 
+ 
 //
+ 
 record.r
@@ -3053,17 +3053,217 @@
 remove()
-;
+ will flag record as removed and delete on server%0A            // when any other change is made. %0A            //pfstore.tree.root.childNodes = _.remove(pfstore.tree.root.childNodes, record);%0A          %7D
 %0A       
@@ -3746,24 +3746,33 @@
 e, store) %7B%0A
+        %0A
         var 
@@ -4853,153 +4853,8 @@
 s',%0A
-//                    %7B%0A//                      text: 'First Milestone',%0A//                      dataIndex: 'Milestone'%0A//                    %7D,%0A
     
@@ -5408,26 +5408,65 @@
 t()%0A        
-%7D)
+  %0A        %7D);%0A      //window.grid = grid
 ;%0A    %7D%0A  %0A%7D

Fix enableHiearchy brakes paging and column picker