1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    50
    Vote Rating
    16
    stevo.zilik will become famous soon enough

      0  

    Default Answered: Ext.data.reader.Json totalProperty with dot "."

    Answered: Ext.data.reader.Json totalProperty with dot "."


    Hi

    I have an usual JSON comming back from server that looks like this:

    Code:
    {
          "values": [...],
          "data.length": 100
    }
    where "data.length" is my totalProperty (number of total records in the dataset, for paging). The problem is when I put "data.length" into my totalProperty, it's trying to be clever and look for a "data" object with a "length" property. Is there any way of telling it not to be clever and just take the name as I've passed it?

    Thanks.
    Stevo

  2. See:

    http://docs.sencha.com/ext-js/4-1/so...createAccessor

    You've got a wealth of options available, such as:

    Code:
    totalProperty: '["data.length"]'
    or:

    Code:
    totalProperty: function(obj) {
        return obj['data.length'];
    }
    or useSimpleAccessors:

    http://docs.sencha.com/ext-js/4-1/#!...impleAccessors

  3. #2
    Ext JS Premium Member saJoshua's Avatar
    Join Date
    Nov 2007
    Location
    South Africa
    Posts
    521
    Answers
    2
    Vote Rating
    5
    saJoshua is on a distinguished road

      0  

    Default


    javascript uses "." (dot) notation internally, so it's not advisable to use it in strings that could get confusing in a similar way to your json being misinterpreted. You wouldn't create an object with a key of "Object", would you?

    {
    "Object" : {}
    }

    Any chance you can change the dot to a different character?

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    50
    Vote Rating
    16
    stevo.zilik will become famous soon enough

      0  

    Default


    Quote Originally Posted by saJoshua View Post
    javascript uses "." (dot) notation internally, so it's not advisable to use it in strings that could get confusing in a similar way to your json being misinterpreted. You wouldn't create an object with a key of "Object", would you?

    {
    "Object" : {}
    }

    Any chance you can change the dot to a different character?
    I agree with you, but unfortunately that's not something I can change. If I could, then I would...

    So I need a solution on js side.

  5. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,574
    Answers
    540
    Vote Rating
    311
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      1  

    Default


    See:

    http://docs.sencha.com/ext-js/4-1/so...createAccessor

    You've got a wealth of options available, such as:

    Code:
    totalProperty: '["data.length"]'
    or:

    Code:
    totalProperty: function(obj) {
        return obj['data.length'];
    }
    or useSimpleAccessors:

    http://docs.sencha.com/ext-js/4-1/#!...impleAccessors

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi