Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
another jsonmap problem
04/02/2009
17:02
Avatar
bgoodin
Member
Members
Forum Posts: 5
Member Since:
05/02/2009
sp_UserOfflineSmall Offline

Sorry for the similar post on this. I have my table rendering. However, it is not placing any values in the cells. I have the following jqGrid setup and json being returned. For some reason 'title.name' is returning nothing. Can you see a reason why jsonmap would not properly lookup the nested value?

jqGrid code:

$("#tableContainer").jqGrid({
    jsonReader:{
      root: "orderlines",
      page: "page",
      total: "total",
      records: "records",
      repeatitems: false,
      id: "id"
    },
    url:'/Cart.action?_eventName=fetchOrderlines&id=' + orderId,
    datatype : 'json',
    colNames:['Title'],
    colModel:[
        {name: 'title.name', index: 'title.name', width:215, align: 'left', jsonmap: 'title.name'}
    ]
}).navGrid('#pagerdt',{edit:false,add:false,del:false});

JSON returned from my URL:

{
    "total": 1,
    "orderlines": [
        {
            "available": false,
            "branchDistribId": 12001390,
            "branches": {

            },
            "callNumber": null,
            "cartCheck": "|Test Cart Symbol",
            "class": "com.mwt.beans.OrderLineExpanded",
            "filled": null,
            "fundId": 8700560,
            "id": 12244008,
            "internalNotes": null,
            "lineItem": null,
            "marcBrief": false,
            "marcOclc": false,
            "marcVolumes": false,
            "mwtPrice": 0.0,
            "notes": null,
            "oclcCost": "$0.00",
            "orderId": 0,
            "otherCartId": 0,
            "previouslyPurchased": false,
            "price": "$39.99",
            "processPrice": "$0.00",
            "product": {
                "available": false,
                "bugHtml": null,
                "bw": false,
                "cardboard": false,
                "cartName": null,
                "catalogName": null,
                "cc": true,
                "circ": "N",
                "clam": false,
                "class": "com.mwt.beans.Product",
                "copyprotect": false,
                "customerPrice": 0.0,
                "dewey": null,
                "displayAfter": null,
                "doubleside": false,
                "dubbed": false,
                "ep": false,
                "format": null,
                "id": 0,
                "img": null,
                "isbn": "9781419848858",
                "isbnOld": null,
                "masterSku": null,
                "media": "HD DVD",
                "miscInfo": "HD DVD & Standard DVD, widescreen",
                "mwtPrice": 0.0,
                "oclc": "141251838",
                "oclcMarcAvailable": false,
                "oclcStatus": null,
                "pieces": 0,
                "preorderDate": null,
                "previousPurchases": 0,
                "priceKey": null,
                "pubSku": null,
                "releaseDate": null,
                "replacements": 0,
                "retailPrice": 0.0,
                "sdh": false,
                "set": false,
                "setId": 0,
                "sku": "WAR113764H",
                "spanish": false,
                "streetDate": 1185858000000,
                "subtitled": false,
                "titleId": 0,
                "upc": "085391137641",
                "used": 0,
                "volume": null,
                "wide": true
            },
            "productId": 11356959,
            "qty": 18,
            "rating": null,
            "replaceQuantities": false,
            "retailPrice": "$39.99",
            "shopperId": 670357,
            "showDetails": false,
            "source": null,
            "spineLabel": null,
            "status": null,
            "statusText": null,
            "subtotal": "$719.82",
            "title": {
                "abridged": false,
                "actors": null,
                "anscr": null,
                "artistFirstName": null,
                "artistLastName": null,
                "artistName": null,
                "boxOfficeGross": 211.0,
                "class": "com.mwt.beans.Title",
                "cleanTitleId": null,
                "comments": 0,
                "country": null,
                "description": null,
                "directors": null,
                "explicitTitleId": null,
                "genre": "Drama",
                "id": 0,
                "img": "war113764h.gif",
                "kind": "VIDEO",
                "language": null,
                "masterSku": null,
                "maxArtistAchievement": null,
                "minutes": 0,
                "muzeId": null,
                "name": "300",
                "notes": null,
                "position": 0,
                "producers": null,
                "products": [

                ],
                "productsInCirc": [

                ],
                "rating": null,
                "ratingDescription": null,
                "releaseYear": null,
                "replacement": false,
                "salesRankAll": 89025,
                "salesRankRecent": 80307,
                "seriesId": 0,
                "studio": null,
                "suggestedAudience": null,
                "year": 0
            }
        }
    ],
    "page": 1,
    "records": 66
}

04/02/2009
19:02
Avatar
bgoodin
Member
Members
Forum Posts: 5
Member Since:
05/02/2009
sp_UserOfflineSmall Offline

I found the code in grid.bas.js which handles the lookup of fields on nested JSON objects.

 else {
    for (j=0;j<f.length;j++) {
        addCell(t,row,cur[f[j]],j+gi+si);
        rd[ts.p.colModel[j+gi+si].name] = cur[f[j]];
    }
}

Specifically here:

cur[f[j]]

This will only look up a field in current (cur) object. It would be nice if nested notation was respected. couldn't we perform an eval to lookup nested properties?

Something like:

for (j=0;j<f.length;j++) {
    addCell(t,row,eval("cur."+f[j]),j+gi+si);
    rd[ts.p.colModel[j+gi+si].name] = eval("cur."+f[j]);
}

I'm not sure what the broader implications of this may be. I tried it in Firefox and it worked. Just wondering if we could use something like this to support standard javascript notations for looking up nested and indexed JSON structures.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
45 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information