设置模型的新属性,而不是将其标记为脏

时间:2014-04-10 15:29:23

标签: extjs extjs4

我有一个商店(有代理'内存')我有一个模型数组,当我创建一个模型时,我使用set(field,newValue)设置了他的propety但是这个方法将它标记为derty ,我想知道我可以设置字段的值而不是标记为脏,这是我的例子:

 for(var i=0;i<questions.length;++i){
        var question=Ext.create('DCM.model.TCL');
        question.set('scope',questions[i].scope);
        question.set('topic',questions[i].topic);
        question.set('area',questions[i].area);
        question.set('target',questions[i].target);
        var responses=questions[i].responses;
        var sumJan=0,nbResponsesJan=0;
        var sumFeb=0,nbResponsesFeb=0;
        var sumMar=0,nbResponsesMar=0;
        var sumApr=0,nbResponsesApr=0;
        var sumMay=0,nbResponsesMay=0;
        var sumJun=0,nbResponsesJun=0;
        var sumJul=0,nbResponsesJul=0;
        var sumAout=0,nbResponsesAout=0;
        var sumSep=0,nbResponsesSep=0;
        var sumOct=0,nbResponsesOct=0;
        var sumNov=0,nbResponsesNov=0;
        var sumDec=0,nbResponsesDec=0;
        for(var j=0;j<responses.length;++j){
            switch(responses[j].month){
                case 0:sumJan+=responses[j].score;++nbResponsesJan;break;
                case 1:sumFeb+=responses[j].score;++nbResponsesFeb;break;
                case 2:sumMar+=responses[j].score;++nbResponsesMar;break;
                case 3:sumApr+=responses[j].score;++nbResponsesApr;break;
                case 4:sumMay+=responses[j].score;++nbResponsesMay;break;
                case 5:sumJun+=responses[j].score;++nbResponsesJun;break;    
                case 6:sumJul+=responses[j].score;++nbResponsesJul;break; 
                case 7:sumAout+=responses[j].score;++nbResponsesAout;break;
                case 8:sumSep+=responses[j].score;++nbResponsesSep;break;
                case 9:sumOct+=responses[j].score;++nbResponsesOct;break;
                case 10:sumNov+=responses[j].score;++nbResponsesNov;break;
                case 11:sumDec+=responses[j].score;++nbResponsesDec;break;    
            }        
        }
        if(nbResponsesJan>0){
            question.set('jan',sumJan/nbResponsesJan);
        }
        if(nbResponsesFeb>0){
            question.set('feb',sumFeb/nbResponsesFeb);
        }
        if(nbResponsesMar>0){
            question.set('mar',sumMar/nbResponsesMar);
        }
        if(nbResponsesApr>0){
            question.set('apr',sumApr/nbResponsesApr);
        }
        if(nbResponsesMay>0){
            question.set('may',sumMay/nbResponsesMay);
        }
        if(nbResponsesJun>0){
            question.set('jun',sumJun/nbResponsesJun);
        }
        if(nbResponsesJul>0){
            question.set('jul',sumJul/nbResponsesJul);
        }
        if(nbResponsesAout>0){
            question.set('aout',sumAout/nbResponsesAout);
        }
        if(nbResponsesSep>0){
            question.set('sep',sumSep/nbResponsesSep);
        }
        if(nbResponsesOct>0){
            question.set('oct',sumOct/nbResponsesOct);
        }
        if(nbResponsesNov>0){
            question.set('nov',sumNov/nbResponsesNov);
        }
        if(nbResponsesDec>0){
            question.set('dec',sumDec/nbResponsesDec);
        }
       questionsModel[i]=question; 
    }
    tclController.getStore('TCL').loadRawData(questionsModel);
 }               

我的网格行看起来像脏记录,如何解决它。

感谢名单。

1 个答案:

答案 0 :(得分:0)

拨打question.commit()即可:

me.phantom = me.dirty = me.editing = false;