Rally Software

 View Only
  • 1.  Issue with filters in custom app Agile Central

    Posted Apr 18, 2018 01:56 AM
      |   view attached

    Hello all,

    I've created one custom app to show the stories having release date greater than corresponding feature release date.

    userstory-->child of -->Feature in the Agile Central.

    The code works fine but it shows output only when SHOW=200.

    This is happening because of the filter condition on custom store.

    filters:[{property:'storiesNotInSyncCount',operator:'!=',value:'0'}] - This condition skips stories that are in sync with feature release

    Please suggest any alternate way to implement this filter condition and also let me know if I'm doing anything wrong.

     

    Below is the full code:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Grid Example</title>

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

       <script type="text/javascript">
            Rally.onReady(function() {
                Ext.define('Rally.example.SimpleGrid', {
                    extend: 'Rally.app.App',
                    componentCls: 'app',
        launch: function() {
           this._makeStore();
           },
           //create a wsapi store containing all the features with specified columns
           _makeStore: function(){
           console.log("in makestore function");
              Ext.create('Rally.data.WsapiDataStore',{
                model:'PortfolioItem/feature',
                fetch:['FormattedID','Name','Release','UserStories','ReleaseDate','ReleaseStartDate'],
                autoLoad:true,
                listeners:{
                  load:this._onFeatureLoaded,
                  scope:this
                  }
              });
            
           },
           //once the store is loaded, iterate through each feature and fetch the required columns
           //along with children(US) count
           _onFeatureLoaded: function(store,data){
           console.log("in _onEpicLoaded function");
              //empty epics=epicArray+featureArray
              var features=[];
              console.log(data.length);
              var pending = data.length;
               if (data.length ===0) {
                this._createFeatureGrid(features); 
               }
              
             
              Ext.Array.each(data,function(feature){
               var featureArray={
               featureFormattedID:feature.get('FormattedID'),
               featureName:feature.get('Name'),
               featureRelease:null,
               totalStoriesCount:feature.get('UserStories').Count,
               storiesNotInSyncCount:0,
               storiesArray:[] };
               
               if(feature.get('Release')!==null)
               {
               console.log("totalStoriesCount="+featureArray.totalStoriesCount);
            
               var stories=feature.getCollection('UserStories');
               stories.load({
                  fetch:['FormattedID','Release','Name','ReleaseDate','ReleaseStartDate','ScheduleState'],
                  callback:function(records,operation,success){
                  
                  var childrenCount=0;
                  var fRelease=feature.get('Release');
                  var fReleaseDate=fRelease.ReleaseDate;
                   Ext.Array.each(records,function(story){
                    var usRelease=story.get('Release');
                    var usReleaseDate=null;
                     if(usRelease!==null){
                      usReleaseDate=usRelease.ReleaseDate;}
                     else{
                      usReleaseDate=null;}
                    
                    console.log('usReleaseDate='+usReleaseDate);
                    console.log('fReleaseDate='+fReleaseDate);
                  if(usRelease!==null)
                  {
                   if((usReleaseDate> fReleaseDate) && (story.get('ScheduleState')!="Accepted"))
                   {
                    featureArray.storiesArray.push({
                    _ref:story.get('_ref'),
                    storyFormattedID:story.get('FormattedID'),
                    storyName:story.get('Name'),
                    storyRelease:usRelease.Name,
                    featureRelease:fRelease.Name,
                    storyScheduleState:story.get('ScheduleState')

                    });
                    console.log('storyFormattedID='+story.get('FormattedID'));
                    console.log('storyName='+story.get('Name'));
                    console.log('storyRelease='+usRelease.Name);
                    console.log('featureRelease='+fRelease.Name);
                    console.log('usReleaseDate='+usReleaseDate);
                    console.log('fReleaseDate='+fReleaseDate);
                    childrenCount=childrenCount+1;
                    console.log("childrenCount="+childrenCount);
                    console.log("storyScheduleState="+story.get('ScheduleState'));
                    
                  }} 
                  },this); 
                  /* if (pending === 0) {
                    this._createFeatureGrid(features);
                   }*/
                 featureArray.storiesNotInSyncCount=childrenCount;
                 featureArray.featureRelease=fRelease.Name;
                 
                 console.log("storiesNotInSyncCount="+featureArray.storiesNotInSyncCount);
                  },
                  scope:this
               });
               
               features.push(featureArray);
               
              }
               console.log("Pending US="+pending);

              },this);
              this._createFeatureGrid(features);
               
           },

           
           //creating custom store with custom model and attributes
           _createFeatureGrid:function(features){
           console.log("in _createFeatureGrid function");
               var featureStoryStore=Ext.create('Rally.data.custom.Store',{
                        data:features,
                        pagesize:25,
                        filters:[{property:'storiesNotInSyncCount',operator:'!=',value:'0'}]
               });

               this.grid=this.add({
                xtype:'rallygrid', 
               // itemId:'epicGrid',
                store:featureStoryStore,
                columnCfgs:[
                {text:'Feature ID',dataIndex:'featureFormattedID',width:30},
                {text:'Feature Name',dataIndex:'featureName',width:100},
                {text:'Feature Release',dataIndex:'featureRelease',width:40},
                {text:'Total Stories',dataIndex:'totalStoriesCount',width:40},
                {text:'Stories NotIn Sync',dataIndex:'storiesNotInSyncCount',width:40},
                {text:'Stories with Releases',dataIndex:'storiesArray',
                    renderer:function(value){
                     var html=[];
                     Ext.Array.each(value,function(story){
                      html.push('<a target="blank" href=" ' + Rally.nav.Manager.getDetailUrl(story) + '">' + story.storyFormattedID+"-"+story.storyRelease+'</a>')
                     });
                     return html.join('<br>');
                    },
                    width:80
                }],
                showRowActionsColumn:false,
                forceFit:true
                
                
               });
               

           }
        
       });
                Rally.launchApp('Rally.example.SimpleGrid', {
                  name: 'Grid Example'
                });
            });
        </script>

        <style type="text/css">
           
        </style>
    </head>
    <body></body>
    </html>

    Attachment(s)

    docx
    Full Code.docx   33 KB 1 version


  • 2.  Re: Issue with filters in custom app Agile Central
    Best Answer

    Broadcom Employee
    Posted Apr 18, 2018 09:32 AM

    Hi Darshana,

     

    Normally supporting or troubleshooting custom code is out of our scope. We will try to assist you as best we can, but keep this in mind. With that said, thank you for including your entire code and highlighting the problem, certainly helping:

     

    I can see your store variable featureStoryStore has a pageSize of 25 and so you defined paging on your store object. I suspect the grid is having trouble working such a store that has a combination of filters and paging.

    We can see your total results are 159 and so it may work with SHOW = 200 because paging isn’t used and all results are in first and only page. You can test this theory by setting your SHOW = 160 and see if that still works because all results are in first page, then set it at SHOW = 158 and it should fail because the store now has more than one page and the grid will not work with it well.

     

    You may want to read this example: https://help.rallydev.com/apps/2.1/doc/#!/example/custom-data-grid , and also the documentation of the Grid object’s

    PagingToolbarCfg at:  https://help.rallydev.com/apps/2.1/doc/#!/api/Rally.ui.grid.Grid-cfg-pagingToolbarCfg . It seems to me that paging will work best if defined on the Grid rather than on the Store.

    The default pageSize for the Grid is 25, it appears to be what you need as well. If so, you may simply remove the pageSize from the Store and just not define it at all. Later, you can then use PagingToolbarCfg to change it.

     

    I’m also noticing that you define the featureStoryStore variable before you create the grid. It could be that if you created this store inside the grid’s creation (as in this example) then perhaps the grid will be able to work with the store’s paging. But, again, I don’t believe store’s paging is recommended anyways.

     

    My suggestion:

    1. First backup this code before you make changes , so you can easily recover.
    2. Remove the pageSize from ‘featureStoryStore’.
    3. If that didn’t help, then create this store within the grid’s creation code block itself. 

     

    Let us know if makes sense and if helped.

     

    Thanks,

    Sagi



  • 3.  Re: Issue with filters in custom app Agile Central

    Broadcom Employee
    Posted Apr 19, 2018 10:48 PM

    Hi Darshana,

    Did that help?

     

    Thanks,

    Sagi



  • 4.  Re: Issue with filters in custom app Agile Central

    Posted Apr 20, 2018 05:35 AM

    Hey Sagi, Thanks for replying...:)

     

    I've tried few steps as per your suggestion:
    1. Removed pagesize from custom store code
    2. Included custom store code into grid creation block
    _createFeatureGrid:function(features){
      console.log("in _createFeatureGrid function");
      this.grid=this.add({
      xtype:'rallygrid', 
        store:Ext.create('Rally.data.custom.Store',{
        data:features,
        filters:[{property:'storiesNotInSyncCount',operator:'!=',value:'0'}]
        }),

        columnCfgs:[
        {text:'Feature ID',dataIndex:'featureFormattedID',width:30},
        {text:'Feature Name',dataIndex:'featureName',width:100},
        {text:'Feature Release',dataIndex:'featureRelease',width:40},
        {text:'Total Stories',dataIndex:'totalStoriesCount',width:40},
        {text:'Stories NotIn Sync',dataIndex:'storiesNotInSyncCount',width:40},
        {text:'Stories with Releases',dataIndex:'storiesArray',
         renderer:function(value){
         var html=[];
         Ext.Array.each(value,function(story){
         html.push('<a target="blank" href=" ' + Rally.nav.Manager.getDetailUrl(story) + '">' + story.storyFormattedID+"-"+story.storyRelease+'</a>')
         });
         return html.join('<br>');
         },
         width:80
         }],
        showRowActionsColumn:false,
        forceFit:true,
        showPagingToolbar: true,
        pagingToolbarCfg: {
           autoScroll: true,
           pageSizes: [100,200]
          }          
        });

     

    It still giving me the same result.

    What I need is all the 5 records satisfying the condition should be displayed as soon as the page loads.

    3.After this, I configured the pagesize in the grid to [100,200]-->SHOW:100/200

    Expected: The grid will show atleast first two records that are on the page in between 1-100 rows.

    Actual: The grid is showing "no records found". Now explicitly I need to select SHOW=200 which shows all the 5 records in range 1-151 and then selecting show=100 shows the 2 records in the range 1-100(But not automatically after page refresh:( )

     

    I'm not able to find out alternate way to apply filter on custom store representing data from two different objects.

    Please let me know if you have any example.

     

    Gud Day:) tc