1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    Seattle
    Posts
    25
    Vote Rating
    0
    SuperSloMo is on a distinguished road

      0  

    Default Mapping Json data to a grid with a different set of columns

    Mapping Json data to a grid with a different set of columns


    I am working on a project in which I need to get a list of Json objects from a web service and use them to populate a grid that contains some of the fields in the Json objects as columns and also contains some columns in which the contents are derived by computing different values that are based on values of fields in the Json objects. It is similar to the Json Grid demo example, but in the demo the grid columns seem to match the fields in the Json objects one to one.

    What is the best way to map the values in fields of Json objects to a different set of values? Are there provisions in the JsonReader class or the classes it uses to map the values differently, or does it work better to read the Json objects directly into a ListStore and then work out a mapping when populating the grid from the ListStore? Or is the best way to do this different from either of those alternatives? Thanks.

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    I dont fully understadn what you are looking for, but your JsonReader should read all the fields that your server sends to you. Than your grid columns can use GridCellRenderes where you can access any stored value and do anyting needed with it.

  3. #3
    Sencha User
    Join Date
    Oct 2010
    Location
    Seattle
    Posts
    25
    Vote Rating
    0
    SuperSloMo is on a distinguished road

      0  

    Default


    Here’s what I’m trying to do:

    First of all, the code I’m working with is passed a JSON string that was obtained by a call to RequestBuilder’s sendRequest function. I’d like to use JsonReader or JsonLoadResultReader to work with the contents of that JSON string, but your Json Grid demo shows a situation in which the RequestBuilder object is included in an HttpProxy object that in turn is used by a BaseListLoader object to get the JSON string and store it in a ListStore object without exposing the JSON string. I don’t understand how to use the constructor and other functions of the JsonReader class when I already have a JSON string that I want to store the contents of in the same way as is done in the Json Grid example.

    So my first question is, is it possible to pass a JSON string in to a JsonReader object in order to get its contents into a ListStore, and if so, how?

    Suppose my JSON string looks like this:

    Code:
    {"players":[
    {"firstName":”Fred”,"lastName":"Smith","atBats":230,"hits":77},
    {"firstName":”Joe”,"lastName":"Brown","atBats":410,"hits":107},
    ….
    }],"numberOfPlayers":40}
    and I want to put the data that I obtain into a grid that has columns named “Name”, “At Bats”, “Hits” and “Batting Average”. The values in the “Name” column should be firstName + “ “ + lastName, and the values in the “Batting Average” column should be hits / atBats.

    My second question is, What is the best way to map the data from the JSON string to the grid columns in a case like this where some conversion is needed? Should I define a ModelType object whose fields match those of the JSON string and a ColumnModel whose list of ColumnConfig objects matches the columns of the grid and then map them somehow after having read the JSON string into a ListStore using that ModelType in the JSonReader? If so, what classes are there that support this kind of mapping? Or is it better to read the JSON string contents straight into a data structure that represents the columns of the grid -- And if so, how do you do that?

    Thanks for your help.

Similar Threads

  1. Nested JSON data and JsonStore mapping question
    By xsikal in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 18 Jun 2010, 7:30 AM
  2. Record mapping data from JSON in form panel
    By richardwyke in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 18 Jul 2009, 8:38 AM
  3. PHP JSON Data Mapping & Search the data
    By saravanan.sbm in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 27 Apr 2009, 10:57 PM
  4. Ext.data.Store won't load with a particular JSON mapping
    By shay2501 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 22 Oct 2008, 1:38 PM
  5. Mapping data model to JSON and loading forms/grids
    By cocorossello in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 28 Feb 2008, 8:16 PM

Thread Participants: 1

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