渲染后ExtJS属性网格重新加载

时间:2015-06-29 14:53:11

标签: javascript extjs

我有一个属性网格:

periods.each(function(record){

var tempPropGrid = me.getView().add(
    {
        xtype:'propertygrid',

        width: 80,
        header: false,
        title: 'prop grid',
        //for some reason the headers are not hiding, we may need to deal with this using CSS
        //hideHeaders: true,
        enableColumnResize: false,
        sortableColumns: false,
        nameColumnWidth: 1,
        source: record.data,
        sourceConfig: {

            periodScrumMaster: {
                editor: Ext.create('Ext.form.ComboBox', {
                    tdCls: 'red',
                    store: team,
                    queryMode: 'local',
                    displayField: 'personName',
                    valueField: 'personName',

                    listeners: {
                        'expand' : function(combo) {
                            var gridvalues = this.up('propertygrid').getSource();
                            combo.getStore().clearFilter(true);
                            combo.getStore().addFilter({property: 'teamName', value: teamName});
                            combo.getStore().addFilter({property: 'periodName', value: gridvalues.periodName});
                            var totalFTE = team.count();
                            console.log(totalFTE);
                            var teamStore = Ext.getStore('personPeriods');
                            console.log('store');
                            console.log(teamStore);
                        },
                    }}),
                displayName: 'Scrum Master'
            },



        },

它有一个渲染侦听器:

 beforerender: function(){

调试器;

                var gridValues = this.getSource();
                // console.log(record);
                //debugger;


                // filter periods for this period only
                periods.filterBy(function(record,id){
                    if(record.get("periodName") === gridValues.periodName){
                        return true;
                    }});

                // filter teamMembers for this period and team
                var view = this.up();
                var vm = view.getViewModel();
                var store = vm.getStore('teamMembers');
                store.filterBy(function(record,id){
                    if(record.get("periodName") === gridValues.periodName)    {
                        return true;
                    }});
                //store.clearFilter(true);
                store.addFilter({property: 'teamName', value: teamName});
                // get FTEs assigned to this team in this period by counting records
                var resourcedFtes = store.count();


                // Here I check the record in the periods store to make sure the data matches up with how many resourcedFte there is an update it if required
                // This is super bad and will need to refactor
                periods.each(function(record,idx){
                    var value = record.get('resourcedFte');
                    if(value != resourcedFtes){
                        record.set('resourcedFte',resourcedFtes);
                        record.commit();
                        vm.data.parentController.saveParent();

                    }});
                // Need to call save parent so that the record is updated when we update it above

                //Clear everything so that we can start fresh next period
                store.clearFilter(true);
                //periods.clearFilter(true);

基本上有一些逻辑可以检查数据是否正确/是最新的,如果没有更新它。这样可以正常工作,但数据不会加载到网格中。渲染网格后我必须刷新才能正确加载。

有没有办法可以在属性网格上调用刷新或重载方法,以便在if语句中再次加载数据?

1 个答案:

答案 0 :(得分:0)

如果我理解你的问题,我会建议你编程商店代理,以便它返回整个更改的记录 您的商店是否已启用autoLoad参与? (对不起,我还不能评论)