拉力网格加载事件未触发

时间:2014-01-29 16:00:25

标签: grid load listener rally

我一直在努力确保Rally.ui.grid.Grid中的load事件被触发,因为我遇到了问题,因为我的Grid没有过滤。我尝试调用方法myStore.setFilter()和myStore.load(),这两个是触发,但我不能确定网格是否正常工作,因为第一次,当它全部加载时,它进行正确的过滤,但是当我更改下拉列表或组合框时它没有。

这是我加载myStore的方式:

this.myStore=Ext.create("Rally.data.wsapi.Store",{
                    model:"Task",
                    autoLoad:true,
                    filters: myFilters,
                    listeners:{
                        load:function(myStore,myData,success){

                            if(!this.myGrid) //IT CREATES THE GRID FOR THE FIRST TIME
                                {
                                    this._loadGrid(myStore)
                                    console.log('Grid Created!');
                                    // this.myStore.setFilter();
                                    // this.myStore.load();
                                }
                                else
                                {
                                    this.myStore.setFilter();
                                    //this.myStore.load();
                                    console.log('Grid reloaded!');
                                    console.log(myFilters);
                                }
                            },
                            scope:this
                        },
                    fetch:["FormattedID","State","Iteration", "Release"]
                }

                )
            }

这就是我加载myGrid的方式:

_loadGrid:function(myStoryStore){
            this.myGrid = Ext.create("Rally.ui.grid.Grid",{
                store:myStoryStore,
                columnCfgs:["FormattedID","State","Iteration", "Release"],
                listeners: {
                    load: function(myGridy){
                        console.log('myGrid did load!');
                    },
                    scope:this
                }
                });

            this.add(this.myGrid);
    }

1 个答案:

答案 0 :(得分:2)

以下是来自his videos on building Rally apps的David Thomas使用reconfigure方法传递商店的示例:_myGrid.reconfigure(myStore)

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',

launch: function() {
    var relComboBox = Ext.create('Rally.ui.combobox.ReleaseComboBox',{
        listeners:{
            ready: function(combobox){
                //console.log('loaded release name', combobox.getRecord().get('Name')); //getRecord() returns currently selected item
                var releaseRef = combobox.getRecord().get('_ref'); 
                this._loadStories(releaseRef);
                //console.log('what is this', this);
            },
            select: function(combobox){
                var releaseRef = combobox.getRecord().get('_ref'); 
                this._loadStories(releaseRef);
            },
            scope: this
        }
    });
    this.add(relComboBox);
},

_loadStories: function(releaseRef){
    console.log('loading stories for ', releaseRef);

    var myStore = Ext.create('Rally.data.WsapiDataStore',{
        model: 'User Story',
        autoLoad:true,
        fetch: ['Name','ScheduleState','FormattedID'],
        filters:[
            {
                property : 'Release',
                operator : '=',
                value : releaseRef
            }
        ],
        listeners: {
            load: function(store,records,success){
                console.log("loaded %i records", records.length);
                this._updateGrid(myStore);
            },
            scope:this
        }
    });
},

_createGrid: function(myStore){
    console.log("load grid", myStore);
    this._myGrid = Ext.create('Ext.grid.Panel', {
        title: 'Stories by Release',
        store: myStore,
        columns: [
                {text: 'ID', dataIndex: 'FormattedID', flex: 1},
            {text: 'Story Name', dataIndex: 'Name', flex: 2},
            {text: 'Schedule State', dataIndex: 'ScheduleState', flex: 2}
        ],
        height: 400
    });
    this.add(this._myGrid);
},

_updateGrid: function(myStore){
    if(this._myGrid === undefined){
        this._createGrid(myStore);
    }
    else{
        this._myGrid.reconfigure(myStore);
    }
}

});