Hi im stuck in this problem for almost a week now i need help to create a server side pagination , sorting , filtering
ive done so many ways i found in internet but non work i already filter the data and its showing the problem is the pagination sorting and filtering
my table initialization
function testing3() {
$("#ModalSearchTable").dataTable().fnDestroy();
var searchVal = $("#ModalSearchValue").val();
var table = $("#ModalSearchTable").dataTable({
"searching": false,
"dom": 'frtip',
responsive: true,
"oLanguage":
{
"oPaginate":
{
"sFirst": "<<",
"sLast": ">>",
"sNext": ">",
"sPrevious": "<"
},
"sLengthMenu": "",
"sZeroRecords": "No Records Found"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '@Url.Action("GetSearchData", "BusinessCenters")',
"fnServerData": function (sSource, aoData, fnCallback) {
/* Add some data to send to the source, and send as 'POST' */
aoData.push({ "name": "searchParam", "value": searchVal })
$.ajax({
"dataType": "JSON",
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"columns": [
{ "data": "Id" ,
"class": "hidden",
"sTitle": "Id",
},
{
"data": "Code",
"sTitle": "Code",
},
{
"data": "Name",
"sTitle": "Name",
}
]
});
}
my jason request
public JsonResult GetSearchData(string searchParam)
{
var bussCtrs = db.BusinessCenters
.Where(x => searchParam == "*" || x.BussCtrCode.Contains(searchParam) || x.BussCtrName.Contains(searchParam))
.ToList()
.Select(x => new { Id = x.BussCtrId, Code = x.BussCtrCode, Name = x.BussCtrName });
return Json(new { aaData = bussCtrs }, JsonRequestBehavior.AllowGet);
}