I am using Jquery Data tables for my project and I am working on Asp.Net MVC 5 and entity framework 6. What I really want to do is just call my stored procedure to be called inside my jquery data tables. For now I am calling the table from my database and the call is a ajax call for jquery data table.
Here is the example of my ajax call for data table.
$('#studentTable').DataTable({
"ajax": {
"url": "/StructuredImportTgts/GetData",
"type": "GET",
"datatype": "json"
},
responsive: 'true',
dom: 'Bfrtip',
buttons: [
'copy', 'excel', 'pdf'
],
"columns": [
{ "data": "PART_NO" },
{ "data": "LEVEL" },
{ "data": "PART_NO" },
{ "data": "PART_NAME" },
{ "data": "L1QTY" },
{ "data": "PL1" },
{ "data": "PL2" },
{ "data": "PL3" },
{ "data": "SupplierLocID" },
{ "data": "SupplierLocID" },
{ "data": "Discrepancies" },
{ "data": "Comments" }
]
The code for GETDATA() is in my controller which is as follows, it calls the table from the database and this is where I need to call my Stored procedure.
public ActionResult GetData()
{
using (Dev_Purchasing_New_ModelEntities db = new Dev_Purchasing_New_ModelEntities())
{
db.Configuration.LazyLoadingEnabled = false;
List<bomStructuredImportTgt> bomStructuredImportTgtList = db.bomStructuredImportTgts.ToList<bomStructuredImportTgt>();
return Json(new { data = bomStructuredImportTgtList }, JsonRequestBehavior.AllowGet);
}
}