Search code examples
javascriptrallycode-rally

Push Grid on Store Load Issue


So i have been working on a custom pivot app to add onto rally and have ran into an issue with adding drill down functionality where a rally grid is loaded below the pivot table with the records that fill the pivot. The issue i am having is on first click the store is created, however the load:function which is supposed to call the _newGrid function never gets called. I don't receive any errors, the load:function is simply never called. Console log on first click shows:

["F22826"] App.js?_dc=0.7585907679242929:241

Create Store

Console log on second click shows:

["F22826"]

Store Exists

Data constructor {config: Object,

fetch: Array[5], autoload: true, filters: constructor, listeners: null…} [constructor, constructor] true

create grid

Hoping someone can help me understand what i am missing

_getFilter: function (data, i) {

                return {
                    property: 'FormattedID',
                    operator: '=',
                    value: data[i]
                };

                //console.log(filter);

                //return filter;

            },

            //Creates the filter based on formatted ID to drill down

            _createDrillMatrix: function (clickData) {
                console.log(clickData);


                var filter = [];


                for (var i = 0; i < clickData.length; i++) {
                    filter.push([this._getFilter(clickData, i)]);
                }
                var finalFilter = JSON.stringify(filter);

                finalFilter = finalFilter.replace(/\[/g, '{');
                finalFilter = finalFilter.replace(/\]/g, '}');
                finalFilter = finalFilter.replace(/^{/, '[');
                finalFilter = finalFilter.replace(/}$/, ']');
                finalFilter = finalFilter.replace(/{{/g, '{');
                finalFilter = finalFilter.replace(/}}/g, '}');
                finalFilter = JSON.parse(finalFilter);
                finalFilter = Rally.data.wsapi.Filter.or(finalFilter);
                //console.log(finalFilter);
                var model= 'PortfolioItem/Feature';
                this._createStore(finalFilter, model);


            },
            _createStore: function(filter, model){

                if (this.filteredStore) {
                    console.log('Store Exists');
                    this.filteredStore.setFilter(filter);
                    this.filteredStore.load();
                } else {
                    console.log('Create Store');
                    this.filteredStore = Ext.create('Rally.data.wsapi.Store', {
                        model: model,
                        fetch: ['FormattedID', 'Name', 'Owner', 'State', 'Release'],
                        autoload: true,
                        filters: filter,
                        listeners: {
                            load: function (myStore, myData, success) {
                                console.log('Data', myStore, myData, success);
                                if (!this.defectGrid) {
                                    console.log('create grid');
                                    this._newGrid(myStore);
                                }
                            },
                              scope: this
                        },

                    }
                    );
                    scope:this;
                }
            },

            //adds grid to display drill down

            _newGrid: function (filteredStore) {

                this.defectGrid = Ext.create('Rally.ui.grid.Grid', {
                    store: filteredStore,
                    columnCfgs: ['FormattedID', 'Name', 'Owner', 'State', 'Release'],
                    limit: Infinity,
                    enableEditing: false,
                });
                this.add(this.defectGrid);

            }

        });

Solution

  • Overall it looks pretty good. Are you getting any console errors? What about errors in your network requests?

    I might suggest one small change in your store config: filters should be an array.

    filters: [filter]