sAjaxSource shows only multiple records

sAjaxSource shows only multiple records

derickmayberryderickmayberry Posts: 6Questions: 0Answers: 0
edited April 2013 in General
If Json document returned from sAjaxSource url only contains one record I will get the "No data available in table" in the table, but if the json doc has multiple records, they render wtihout a problem. Any help would be greatly appreciated, I know I'm just missing something somewhere.

My JQuery:

[code]
var oTable = $('#applicationTableAjax').dataTable({
"bProcessing": true,
"sAjaxSource": AjaxUri,
"sAjaxDataProp": "applications.application",
"bPaginate": true,
"bDeferRender":true,
"aoColumns": [
{ "mData": "applicationId" },
{ "mData": "applicationName" },
{ "mData": "applDesc" },
{ "mData": "businessArea.businessAreaName" },
{ "mData": "links.link.3.@href" }
],
"aoColumnDefs": [
{
"mRender": function(data, type, row){
var uri = "/admin/products?prodURI=";
var fullUri = uri + data;
var x = fullUri + "&appURI=" + AjaxUri;
return "View Products";
},
"aTargets": [ 4 ]
}
]
});
[/code]

and my json document:

[code]
{
"applications":
{
"application":
{
"createTs": "2013-04-08T14:08:21.118-05:00",
"createUserid": "test",
"lastChangeTs": "2013-04-08T14:08:21.118-05:00",
"lastChangeUserid": "test",
"version": "143",
"links":
{
"link":
[
{
"@href": "http://localhost:8080/translator-web/businessareas/16/applications/1",
"@rel": "delete"
},
{
"@href": "http://localhost:8080/translator-web/businessareas/16/applications/1",
"@rel": "self"
},
{
"@href": "http://localhost:8080/translator-web/businessareas/16/applications/1",
"@rel": "update"
},
{
"@href": "http://localhost:8080/translator-web/businessareas/16/applications/1/products",
"@rel": "products"
},
{
"@href": "http://localhost:8080/translator-web/businessareas/16",
"@rel": "parent",
"@title": "",
"@type": ""
}
]
},
"messages": null,
"applDesc": "test",
"applicationId": "1",
"applicationName": "test",
"businessArea":
{
"createTs": "2013-04-08T14:08:21.075-05:00",
"createUserid": "test",
"lastChangeTs": "2013-04-08T14:08:21.075-05:00",
"lastChangeUserid": "test",
"version": "120",
"links": null,
"messages": null,
"businessAreaDesc": "WebTest",
"businessAreaId": "16",
"businessAreaName": "logistics"
},
"businessAreaId": "16"
}
},
"totalMatchingApplications": "16"
}


[/code]

Replies

  • derickmayberryderickmayberry Posts: 6Questions: 0Answers: 0
    and by record I mean one application as it relates to my json document.
  • derickmayberryderickmayberry Posts: 6Questions: 0Answers: 0
    Found the issue.. when the server is sending json back, if its only one record it leaves off the [ ] brackets... Datatables obviously has to have these. Once I fixed that everything is working fine.
This discussion has been closed.