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.

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Netherlands
    Posts
    87
    Vote Rating
    0
    macs is on a distinguished road

      0  

    Default access a model property from a field convert function

    access a model property from a field convert function


    i add a property to a model with default value 50 before it is instantiated like shown below.

    Code:
    var propertyValue = 50;
    this.myStore.getModel().addStatics({
          modelProperty: propertyValue,  
    });
    this.myStore.load();
    i then want to access this property from a field convert function like below, however, this returns 'undefined' in the log. also when i hard code the property in the model, i am not able to access its value. Is there a way to do this? many thanks in advance for any suggestions

    //i omitted the rest of the snippet for the ease of reading
    Code:
    fields: [
       {name: 'id'},
       {name: 'distance', 
           convert: function (value, record) {
               console.log(this.modelProperty)
           },
        },
    ],

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Try this:-

    Code:
    var propertyValue = 50;
    this.myStore.getModel().addStatics({
       modelProperty: propertyValue,  
    });
    this.myStore.load();
    instead of
    var propertyValue = 50;

    try
    this.propertyValue = 50;

    also remove ',' after
    propertyValue in addStatistics
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Netherlands
    Posts
    87
    Vote Rating
    0
    macs is on a distinguished road

      0  

    Default


    thanks sword-it for the suggestion. however the question was not so much about how can i put the property in the model, but rather how can i access it from the fields convert function? as i said also when i put the property hard coded into the model i am not able to access it form the fields convert function.

  4. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    154
    Vote Rating
    3
    coolfish is on a distinguished road

      0  

    Default


    The static property or function will be added to the Model (class) is my guess, but not to instantiated objects of that model. So in your convert function you'd use it along the lines of

    Code:
    function convert(v, record)
    {
        var adjustedValue = MyApp.model.MyClass.myStaticProperty + record.foo ;
        return adjustedValue;
    }

Thread Participants: 2

Tags for this Thread