DataTable with rendered html
DataTable with rendered html
I asked this question also before this one I have a problem in am working on a big project I am calling an api through ajax and then creating whole table wtith returned data in json form. Here is my code after getting reponse
incomingTransferBondRequests.processMainBondRequestTableView = function(response) {
var $html = '';
incomingTransferBondRequests.loadBondRequestDetail(response);
if(response.status==1){
incomingTransferBondRequests.request_count=0;
if(typeof response.list_of_requests != 'undefined' && !$.isEmptyObject(response.list_of_requests)) {
incomingTransferBondRequests.request_count += response.list_of_requests.length;
$html += '
Request # | '; $html += 'Defendant name | '; $html += 'Company Name | '; $html += ''; $html += ' | Action | '; $html += '|
---|---|---|---|---|---|
'+value.Id+' | '; $html += ''+value.DefendantName+' | '; $html += ''+value.SenderCompanyName+' | '; if(value.Read == 0) { $html += 'New | '; } else { $html += 'Read | '; } $html += ''; $html += 'View Detail'; $html += ' | '; $html += '
';
$('#maindiv').html($html);
if(incomingTransferBondRequests.default_list_size > response.list_of_requests.length) {
$('#load_more').addClass('hidden');
} else {
$('#load_more').removeClass('hidden');
}
} else {
var page_count = parseInt(incomingTransferBondRequests.request_count/20, 10) || 0;
if(page_count) {
showErrorMessage('Sorry! no more records to display');
} else {
$html += '
';
$('#maindiv').html($html);
showErrorMessage('Sorry! you have not received any request yet');
}
}
}else {
showErrorMessage(response.message);
}
waitingDialog.hide();
};
Can i initialize this with datatable in which sorting,searching and filter will work how can I do that. Thanks!