Search code examples
extjsextjs4.1sencha-architectextjs4.2

How to insert records for particular store field in extjs


I am getting Month, Target, Target1 values are getting from webservice available in store. I want to calculate the total value and insert the total field value in the same store.

I am doing this for calculation but I don't know how to insert the total value into the total field. Can anybody tell me how to do this?

chartstore.each(function (rec) {                   
    total=parseFloat(rec.get('target'))+parseFloat(rec.get('target1'));
});

Month Target Target1   Total

 Jan    25     25       50
 Mon    50     50       100

Solution

  • You should use convert function in your model for total field like below

         {
            name : 'total',
            convert : function( value, record ) {
                           var totalValue = record.get('Target') + record.get('Target1');
                           return totalValue;
            }   
            type: 'number'
        },