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 User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Answers
    498
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar