DataTable with rendered html

DataTable with rendered html

waheed.imtiazwaheed.imtiaz Posts: 1Questions: 5Answers: 0

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 += '

'; $html += '
'; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $html += ''; $(response.list_of_requests).each(function(key, value) { $html += ''; $html += ''; $html += ''; $html += ''; if(value.Read == 0) { $html += ''; } else { $html += ''; } $html += ''; $html += ''; }); $html += ''; $html += '
Request #Defendant nameCompany NameAction
'+value.Id+''+value.DefendantName+''+value.SenderCompanyName+' New Read'; $html += 'View Detail'; $html += '
'; $html += '
'; $html += ' Load More'; $html += '
'; $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 += '

'; $html += '
'; $html += '
'; $html += '
'; $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!

This discussion has been closed.