hi,
how to load datatables passing parameter asp.net mvc
everything look god bot there is no show data
<link href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" type="text/javascript"></script>
<div class="row" style="margin-left:150px">
<div class="col-lg-12" style="background-color: white;
padding: 15px;">
<button id="btnGet" name="btnGet">GetData</button>
<input type="text" id="txtID" name="txtID" class="form-control" />
<br />
<table id="tblFilter" class="table table-bordered table-striped" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Ana Menü Kodu</th>
<th>Ana Menü Adı</th>
<th>Ikon Adı</th>
</tr>
</thead>
</table>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#btnGet').on("click", function () {
var ID = $("#txtID").val();
$('#tblFilter').DataTable({
'destroy': true,
"processing": true,
"serverSide": true,
"columns": [
{ "data": "ID", "autoWidth": true },
{ "data": "MAINMENUCODE", "autoWidth": true },
{ "data": "MAINMENUNAME", "autoWidth": true },
{ "data": "ICON", "autoWidth": true }
],
"ajax": {
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": "/System/IndexFilter",
data: { ID: ID }
}
});
});
});
</script>
public JsonResult IndexFilter(int ID)
{
using (DbContext db = new DbContext())
{
Mainmenu employees =new Mainmenu();
var status = "Ok";
try
{
employees = db.Mainmenus.Where(x => x.ID == ID).FirstOrDefault();
}
catch (Exception mesaj)
{
status = mesaj.Message;
}
return Json(new { status=status,data = employees }, JsonRequestBehavior.AllowGet);
}
}