After digging around on the board I was able to modify a demo to call into an MVC 6 JsonResult Action but I can not get the data to load into the grid. I can enter debug mode in Visual Studio and do see the AJAX call into the Action and that the action is returning a result containing 1 record (which is the right amount of records). The grid then load into the web page but no data inside is displayed just the words "No rows to Display." What am I doing wrong?
JavaScript Code:
<script>
$(function ()
{
var colModel = [
{ title: "ID", width: 100, dataType: "integer", dataIndx: "ID" },
{ title: "Name", width: 500, dataType: "string", dataIndx: "Name" }
];
var dataModel =
{
location: "remote",
dataType: "json",
method: "POST",
contentType: "application/json; charset=UTF-8",
url: '@Url.RouteUrl("GetChangeOrders")',
getData: function (dataJson)
{
var data = dataJson.data;
return { data: data };
}
};
var obj =
{
title: "Test",
dataModel: dataModel,
colModel: colModel,
};
$("#Grid").pqGrid(obj);
});
</script>
c# Code:
[Route("GetChangeOrders", Name = "GetChangeOrders")]
public JsonResult ChangeOrders()
{
var ChangeOrdersList = _DbContext.ChangeOrders.Select(co => new { ID = co.ID, Name = co.Name }).ToList();
return Json(ChangeOrdersList);
}