Can't populate table with 12 rows of data

Can't populate table with 12 rows of data

dwschulzedwschulze Posts: 8Questions: 0Answers: 0
edited January 2014 in General
I try to populate a table with 12 rows of data and I get nothing in the table and it reports 2264 entries. I have not idea how it could get 2264 entries for my data.

The JSON and code are below. I've checked the JSON with JSONlint.

Feedback would be appreciated. I'm running out of time to get a jquery table plugin that works.


[code]
[{"productId":47208998,"serialNumber":"09890s8","sONumber":"dev35001484","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47208999,"serialNumber":"9847rew","sONumber":"34543","partNumber":"54321-C","desc":"BD BLANK LNA Q","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209000,"serialNumber":"07809780978","sONumber":"dev350","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209001,"serialNumber":"09709709790","sONumber":"dev35001594","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209002,"serialNumber":"843432k375","sONumber":"","partNumber":"54400-10","desc":"Radio - Field Replacement, SNB900, US/Canada","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209003,"serialNumber":"843432k375","sONumber":"4556","partNumber":"54400-10","desc":"Radio - Field Replacement, SNB900, US/Canada","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209004,"serialNumber":"09780978097809","sONumber":"dev35001484","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209005,"serialNumber":"07809808098","sONumber":"","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209006,"serialNumber":"fafa","sONumber":"dev35001484","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209007,"serialNumber":"1234xyz","sONumber":"1234","partNumber":"54200-00","desc":"TRIMTRAC BASE Non-RoHS","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209008,"serialNumber":"0909090","sONumber":"dev35001484","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"},{"productId":47209009,"serialNumber":"0909090","sONumber":"dev35001484_","partNumber":"987654KP-GL","desc":"TEST MEC","shippedDate":null,"soldDate":null,"status":"Awaiting Validation"}]
[/code]

[code]







$(function() {


$.ajax({
url:"/mtprest/Product/productByStatus?status=awaiting",
success:function(result){

var jsonaaData = JSON.stringify(result.aaData)
console.log(jsonaaData);

debugger
$("#example").dataTable({
"aaData": jsonaaData,
"aoColumns": [
{"mData": "serialNumber", sDefaultContent: ""},
{"mData": "sONumber", sDefaultContent: ""},
{"mData": "partNumber", sDefaultContent: ""},
{"mData": "desc", sDefaultContent: ""},
{"mData": "shippedDate", sDefaultContent: ""},
{"mData": "soldDate", sDefaultContent: ""},
{"mData": "status", sDefaultContent: ""}
]
});
},
failure: function(result){
alert("Failed");
}

});
});









Serial Number
Sales Order
Part Number
Part Description
Shipped Date
Date Sold
Status









[/code]

Replies

  • dwschulzedwschulze Posts: 8Questions: 0Answers: 0
    Forgot to include my Debugger bookmark:

    http://debug.datatables.net/ibofal
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > jsonaaData = JSON.stringify(result.aaData)

    Why are you converting the data to a string? Just pass it in as an array! The aaData documentation notes that it takes an array, not a string.

    Allan
  • dwschulzedwschulze Posts: 8Questions: 0Answers: 0
    [code]"aaData": result.aaData[/code]

    That solved it. Thanks.
This discussion has been closed.