Create Json as input to jQuery DataTables

Create Json as input to jQuery DataTables

Hello,
I'm attempting to use the "aaData" property of jquery DataTables plugin, but having a problem rendering my table when I pass it a Json formatted variable.

My table does exists in the Html section of the page with id="pftable" , so now I just need to call DataTables like this:

  $('#pftable').dataTable()

with the use of the "aaData"  property.

It works as follows, but with only one record. I can't however figure out how to ADD to the JsonTest variable :

Copy code
  1.   var JsonTest = { "aaData": [] };
  2.         JsonTest =
  3.             {
  4.                 "PfId": "1000",
  5.                 "Name": "Bob Jr.",
  6.                 "ExpType": "Hs Var",
  7.                 "Date": "05/01/1967",
  8.                 "Term": "term 123",
  9.                 "Exposure": "55,000,000"
  10.             };
  11.   var oTable = $('#pftable').dataTable({             
  12.             "aaData": [JsonTest],
  13.             "aoColumns":[
  14.                 { "mData": "PfId" },
  15.                 { "mData": "Name" },
  16.                 { "mData": "ExpType" },
  17.                 { "mData": "Date" },
  18.                 { "mData": "Term" },
  19.                 { "mData": "Exposure" }
  20.             ],
  21.             'aoColumnDefs': [                              
  22.                 { "sTitle": "Pf Id", "aTargets": [0] },    
  23.                 { "sTitle": "Name", "aTargets": [1] },
  24.                 { "sTitle": "Exp Type", "aTargets": [2] },
  25.                 { "sTitle": "Date", "aTargets": [3] },
  26.                 { "sTitle": "Term", "aTargets": [4] },
  27.                 { "sTitle": "Exposure", "aTargets": [5] },
  28.             ]
  29.         });

The DataTable DOES NOT render when I add records as follows:


Copy code
  1.         JsonTest =
  2.             {
  3.                 "PfId": "1000",
  4.                 "Name": "Bob Jr.",
  5.                 "ExpType": "Hs Var",
  6.                 "Date": "05/01/1967",
  7.                 "Term": "term 123",
  8.                 "Exposure": "55,000,000"
  9.             };
  10.         JsonTest +=
  11.             {
  12.                 "PfId": "11000",
  13.                 "Name": "James",
  14.                 "ExpType": "Hs Var",
  15.                 "Date": "06/14/2003",
  16.                 "Term": "term 123",
  17.                 "Exposure": "56,000,000"
  18.             };        


Can someone help me to properly format my Json object so I can ADD records to it, and subsequently render my DataTable ?

thanks.
Bob