I'm having issues getting my data to display in my view in my MVC project. When I load the page based on the value I send it all the controls pop up, but no data. I'm only trying to use DataTables on the PartialSlagView right now so that is where the issues are. Any help is appreciated.
The code in my view that calls the partial view looks like this:
The code in my partial view looks like this:
The code in my controller looks like this:
The code in my view that calls the partial view looks like this:
@if(ViewBag.SearchKey != null) { @Html.Action("PartialChemAnalysis", "Home", (string)ViewBag.SearchKey) @Html.Action("PartialSlagView", "Home") }
The code in my partial view looks like this:
<script type="text/javascript" src="../../Scripts/jquery-1.9.1.js"></script> <script type="text/javascript" src="../../Scripts/FixedColumns.min.js"></script> <script type="text/javascript" src="../../Scripts/jquery.dataTables.js"></script> <script type ="text/javascript" src="../../Scripts/jquery.jeditable.mini.js"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function () { var oTable1 = $('#myDataTable').dataTable({ "bServerSide": true, "sAjaxSource": '/Home/AjaxCall', "fnDrawCallback": function () { $('#myDataTable tbody td:nth-child(2)').editable('/Home/Write/', { "callback": function (sValue, y) { oTable1.fnDraw(); }, }); } }); }) </script> <table id ="myDataTable" class="display"> <thead> <tr> <th>Analysis ID</th> <th>Name</th> <th>Analysis Time</th> <th>Sample Type</th> <th>Grade</th> <th>Product ID</th> </thead> <tbody> </tbody> </table>
The code in my controller looks like this:
public ActionResult PartialSlagView() { return PartialView(); } public ActionResult AjaxCall(jQueryDataTableParamModel param) { PartialSlagViewModel D = new PartialSlagViewModel(); IEnumerable<PartialSlagViewModel> model = D.SlagList; D.SlagViewDataPull(heatName); return Json(new { sEcho = param.sEcho, iTotalRecords = D.SlagList.Count(), iTotalDisplayRecords = D.SlagList.Count(), aaData = D.SlagList }, JsonRequestBehavior.AllowGet); }