Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

Hybrid View

  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    49
    Answers
    2
    Vote Rating
    0
    chaddjohnson is on a distinguished road

      0  

    Default Answered: model.convert() not called when accessing field via model.get()

    Answered: model.convert() not called when accessing field via model.get()


    I have the following model:
    Code:
    (function() {
    
      var fourDecimals = function(value, record) {
        return parseFloat(value.toFixed(4));
      }
      
      Ext.define('App.model.Stock', {
        extend: 'Ext.data.Model',
        fields: [
          {name: 'Symbol',             type: 'string'},
          {name: 'TradePrice',         type: 'float'},
          {name: 'Bid',                type: 'float'},
          {name: 'Ask',                type: 'float'},
          {name: 'Volume',             type: 'int'},
          {name: 'TodaysClose',        type: 'float'},
          {name: 'PreviousClose',      type: 'float'},
          {
            name: 'PriceChange',
            type: 'float',
            convert: function(value, record) {
              return parseFloat((record.get('TradePrice') - record.get('PreviousClose')).toFixed(4));
            }
          },{
            name: 'PercentPriceChange',
            type: 'float',
            convert: function(value, record) {
              return parseFloat((((record.get('TradePrice') / record.get('PreviousClose')) - 1) * 100).toFixed(2));
            }
          }
        ]
      });
    
    })();
    When I call do the following, the convert() function is not called for my model instance:

    Code:
    model.set('TradePrice', 12.34);
    var priceChange = model.get('PriceChange');
    Is this a bug?

  2. This does work in Sencha Touch 2. When a field that a convert() function depends on is updated, the convert() function is called.

    I found a workaround based on this blog post:

    Code:
    set: function(fieldName, newValue) {
      this.callParent(arguments);
    
      // Force recalculation of dependent fields.
      if (typeof fieldName == 'object' || fieldName == 'TradePrice' || fieldName == 'PreviousClose') {
        this.set('PriceChange');
        this.set('PercentPriceChange');
      }
    }
    I added that to the model.

  3. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    49
    Answers
    2
    Vote Rating
    0
    chaddjohnson is on a distinguished road

      0  

    Default


    This does work in Sencha Touch 2. When a field that a convert() function depends on is updated, the convert() function is called.

    I found a workaround based on this blog post:

    Code:
    set: function(fieldName, newValue) {
      this.callParent(arguments);
    
      // Force recalculation of dependent fields.
      if (typeof fieldName == 'object' || fieldName == 'TradePrice' || fieldName == 'PreviousClose') {
        this.set('PriceChange');
        this.set('PercentPriceChange');
      }
    }
    I added that to the model.