I want to bind data to a table using jQuery DataTables.
I am returning the data using action result and converting it to JSON in view, data is not displaying in the table, only blank columns are shown.
Here is the view part
@model Guardian.Core.Model.Models.PatientMedicationsCollection
@{
var ModelJsonData = Newtonsoft.Json.JsonConvert.SerializeObject(Model);
Layout = null;
}
<script type="text/javascript">
var MedicationMasterData = JSON.parse(@Html.Raw(Json.Encode(ModelJsonData)));
var CCDAChecked;
var LatestCCDA;
var AllCCDA;
var CLaimsChecked;
var AllClaims;
var Last6Month;
var OneYear;
var FilteredData = [];
$(document).ready(function () {
debugger;
$.each(MedicationMasterData, function (idx, obj) {
FilteredData.push(this);
});
FilterTable(MedicationMasterData);
});
function FilterTable(FilteredData) {
debugger;
FData = JSON.stringify(FilteredData)
$('#PatientMedications').DataTable({
"scrollX": 100,
"paging": true,
"pagingType": "full_numbers",
"dom": '<"toolbar">frtip',
"aaData": FData,
columns: [
{ title: "PatientID" },
{ title: "FirstName" },
{ title: "LastName" },
{ title: "DOB." },
{ title: "Gender" },
{ title: "Source" },
{ title: "SourceCreatedDate" },
{ title: "SourceKeyID" },
{ title: "LatestCCDA" },
{ title: "Code" },
{ title: "CodeType" },
{ title: "DrugName" },
{ title: "DrugDecriptionsM" },
{ title: "StartDate" },
{ title: "StopDate" },
{ title: "Instructions" },
{ title: "Status" },
{ title: "DoseQuantity" },
{ title: "RateQuantity" },
{ title: "RateQuantityUnit" },
{ title: "DrugDecriptionsM" },
{ title: "ClaimLineFromDate" },
{ title: "DaysSupply" },
{ title: "DOSAGEFORMNAME" },
{ title: "ROUTENAME" },
{ title: "ST" }
]
});
Controler Part where we are returning the data using action result
public ActionResult PatientMedications(int patientID)
{
return PartialView(patientrepository.PatientMedications(patientID));
}
return Json(new { aaData=