Sourabh Choubey

Sourabh Choubey

  • NA
  • 145
  • 7.6k

I want a common jquery datatable grid function for all the

Mar 15 2018 10:41 AM
I want a common jquery datatable grid function for all the module page.
I want to display the jquery datatable.But i want only one function for it.
I want all the module will display the list by calling to a single jqueryfunction to display data ,sorting and paging
I want to write a function which will accept tablename,url,columnnamename,pagelength,pagesize and passed it to the function
This is what i am using in my code but this is for single module.I dont want to write for every modulelist.
 
$(document).ready(function () {
$('#TableId').DataTable(
{
"scrollX": true,
'columnDefs': [{
'targets': 0,
'searchable': false,
'orderable': false,
'className': 'dt-body-center',
'render': function (data, type, full, meta) {
return '<input type="checkbox" Id="' + $('<div/>').text(data).html() + '" name="Chk" value="' + $('<div/>').text(data).html() + '">';
}
}],
"language":
{
"processing": "<div class='overlay custom-loader-background'><i class='fa fa-cog fa-spin custom-loader-color'></i></div>"
},
"pageLength": 10,
"processing": true,
"serverSide": true,
"ajax":
{
"url": "/a/blist",
"type": "POST",
"dataType": "JSON"
},
"columns": [
{ "data": "Ischecked" },
{ "data": "ID" },
//{ "data": "PatientName" },
{
"data": "PatientName",
"render": function (data, type, row, meta) {
if (type === 'display') {
data = '<a onclick="GetClaimsDetails(' + row.ID + ')">' + data + '</a>';
}
return data;
}
},
//{ "data": "PatientName" },
{ "data": "PracticeName" },
{ "data": "ProcedureCode" },
{ "data": "TotalBalance" },
{ "data": "TotalCharges" },
{ "data": "TypeOfService" },
{ "data": "Status" },
]
});
});