Object of objects server response to datatable

Object of objects server response to datatable

xzbdxzbd Posts: 3Questions: 0Answers: 0
edited June 2013 in General
Hello i'm having
[code]{
"name": "Ürün1",
"description": null,
"link": "www.google.com",
"picture": "",
"currencyId": {
"description": "Türk Lirası",
"symbol": "TL",
"tableName": "currency",
"id": "1"
},
"price": "10",
"companyId": {
"description": "",
"symbol": null,
"tableName": "company",
"id": "1",
"name": "Ikea",
"link": "",
"logo": "",
"order": "0",
"active": "0"
},
"active": "1",
"width": "10",
"height": "10",
"order": "1",
"tableName": "product",
"id": "1",
"desription": "Ürün açıklaması"
}[/code]

server response. And i'd like to get currencyId's description field, and name field for companyId How should i define aoColumns?? Or is this possible?
Thank you

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    How would you show repeated content in an object? Surely the whole point of a table is for multiple entries of a given type of data (perhaps the object above). So how can it be an object of objects? Or are you only ever showing 1 row?

    Allan
  • xzbdxzbd Posts: 3Questions: 0Answers: 0
    Actually, i solved the problem. In my table, i'm showing my products. Because of normalization i don't want to mix product and company table so in product table company id refers to a row which in company table.

    In configuration of datatables i used [code]"aoColumns" : [
    { "mData" : "picture" },
    { "mData" : "name" },
    { "mData" : "description" },
    { "mData" : "link" },
    { "mData" : "price" },
    { "mData" : "companyId.name" }, //ACCESSING OBJECT OF OBJECT
    { "mData" : "name" },
    { "mData" : "active" } ,
    { "mData" : null }

    ],[/code]

    and it resolved my issue by using the row commented above.. Thanks for your consideration.
This discussion has been closed.