Add MANY rows to table

Add MANY rows to table

metuck2metuck2 Posts: 2Questions: 0Answers: 0
edited January 2012 in General
Hey,
I am trying to figure a way of looping over my JSON response and adding rows to the table. I tried using the server side functions but the data is not on the first level so I can't pull the data using that. I also tried adding rows by doing this:

[code]
$.each(data.data.messages, function(index, value) {
$content.find("table.tabledata").dataTable().fnAddData( [
value.subject,
value.datetime,
value.status,
value.attachment,
value.poll
] );
});
[/code]

Here is what I get back from the server to put on the table
[code]
{
successful: "true",
data: {
success: "true",
messages: [
{
subject: "Subject-1",
datetime: "1/9/12 3:53 pm",
status: "32/26/2",
attachment: "0",
poll: "Y"
},
{
subject: "Subject-2",
datetime: "1/8/12 3:53 pm",
status: "32/26/2",
attachment: "1",
poll: "N"
},
{
subject: "Subject-3",
datetime: "1/7/12 3:53 pm",
status: "32/26/2",
attachment: "2",
poll: "Y"
},
{
subject: "Subject-4",
datetime: "1/6/12 3:53 pm",
status: "32/26/2",
attachment: "3",
poll: "N"
},
{
subject: "Subject-5",
datetime: "1/5/12 3:53 pm",
status: "32/26/2",
attachment: "4",
poll: "Y"
},
{
subject: "Subject-6",
datetime: "1/4/12 3:53 pm",
status: "32/26/2",
attachment: "5",
poll: "N"
},
{
subject: "Subject-7",
datetime: "1/3/12 3:53 pm",
status: "32/26/2",
attachment: "6",
poll: "Y"
},
{
subject: "Subject-8",
datetime: "1/2/12 3:53 pm",
status: "32/26/2",
attachment: "7",
poll: "N"
},
{
subject: "Subject-9",
datetime: "1/1/12 3:53 pm",
status: "32/26/2",
attachment: "8",
poll: "Y"
},
{
subject: "Subject-10",
datetime: "12/31/11 3:53 pm",
status: "32/26/2",
attachment: "9",
poll: "N"
}
]
}
}
[/code]
and I want to put this information into the table. Here is the code I am using to do that but no good yet.
[code]
var oTable = $content.find("table.tabledata").dataTable({
"sPaginationType": "full_numbers"
"bProcessing": true,
"sAjaxDataProp": "data.messages",
"sAjaxSource": "http://link",
"aoColumns": [
{ "mDataProp": "Subject" },
{ "mDataProp": "Date/Time" },
{ "mDataProp": "Status" },
{ "mDataProp": "Attachment" },
{ "mDataProp": "Poll" }
]
})
[/code]
And here is the table
[code]



SubjectDate/TimeStatusAttachmentPoll




Loading data from server




SubjectDateDateAttachmentPoll



[/code]
Thank you for any help.
This discussion has been closed.