1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    21
    Vote Rating
    0
    newuser7000 is on a distinguished road

      0  

    Default ArraySstore mixed with jsonStore

    ArraySstore mixed with jsonStore


    I am developing web services using SA, I have code that is opening a query and returning it. using chrome, the return of a query looks like this:
    Code:
    {"page":"2","total":2,"records":"13","rows":[{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]},{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]},{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]}],"userdata":{"amount":600,"tax":120,"total":720,"name":"Totals:"}}
    My co-worker, who is doing the java script side, says this is not standard json format, and she can't work with it. (she is looking for name value pairs, and says this is not it).

    I would like to place column data the array corresponding to the column name array index like:

    colNames = ['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'];

    and the data array for record ID = 3 is:

    ["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]

    How can I do it?

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,264
    Vote Rating
    72
    aconran is a glorious beacon of light aconran is a glorious beacon of light aconran is a glorious beacon of light aconran is a glorious beacon of light aconran is a glorious beacon of light

      0  

    Default


    newUser7000 -

    I don't know what server-side language you are using but it should be easy to transform your arrays into objects. What you've output is similar to how ColdFusion outputs queries if you directly convert them.

    Alternatively, Steve Cutter Blades has done some work to read data in this type of format:
    http://cfqueryreader.cutterscrossing.com/
    http://www.sencha.com/forum/showthre...ry-Data-Reader

    The pro of this is it will take up far less data when transferred across the wire; the con is that it is a little more difficult to read/debug the data being transferred over the wire.
    Aaron Conran
    @aconran
    Sencha Architect Development Team