Inject JSON data from API call into Datatables

Inject JSON data from API call into Datatables

oktavianidewioktavianidewi Posts: 1Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
Hi all, I got some problems when I'm trying to display list of my customer into datatables. The list of my customer is got from API Call and the result is returned into json format.

becouse the result is in json format, so I decided to use getJSON and inject the data results into table. This is my code :

[code]
$.getJSON('<?php echo base_url();?>customer/all_customer', function(data){
var items = [];
items.push('');
items.push('IDCustomer NameEmailCompanyWowCompanyAction');
items.push('');
console.log(data);
$.each(data.customers, function(index, array_data)
{
items.push
(
'' +
'' + array_data.customer_id + '' +
'' + array_data.salutation + ' ' + array_data.first_name + ' ' + array_data.middle_name + ' ' + array_data.last_name +'' +
'' + array_data.primary_email_address +'' +
'' + array_data.company_name +'' +
'' + array_data.company_id +'' +
'Action' +
''
);
});
items.push('');
items.push('');
//$('#example').dataTable();
$('', {
html: items.join('')
}).appendTo('#result');
});
[/code]

the data is displayed in the table, but I can't find the search box, combo box and paging. The datatables is not loaded. How can I load the data into datatables?
This discussion has been closed.