Hello all,
I wasn't sure where to put this as my grids are working...the problem is when I'm trying to pass the data from those grids into an ajax post...they keep coming up with an empty collection. When I step through the jquery...the switches grid has 124 records and the goldList grid has over 1000, but when I hit the breakpoint in the controller the collections are empty.
Here's the JQuery
function SwitchesModalCloseEvent(e)
{
var switchesGrid = $("#SwitchModalGrid").data("kendoGrid");
var goldListGrid = $("#ThirdPartyOpticsGoldListGrid").data("kendoGrid");
var switchesGridObjects = switchesGrid._data; //.dataItems(); //.dataSource.data();
var goldListGridObjects = goldListGrid._data;
var goldListAddActionURL = '@Url.Action("AddToThirdPartyOpticsGoldList", "ThirdPartyOpticsGoldList")';
$.ajax(
{
contentType: "application/json",
data: { switchObjects: JSON.stringify(switchesGridObjects), goldListObjects: JSON.stringify(goldListGridObjects) },
dataType: "json",
type: "POST",
url: goldListAddActionURL
})
.done(function () { alert('Website Called') })
.error(function (objAjaxRequest, strError) {
var respText = objAjaxRequest.responseText;
console.log(respText);
});
}
Here's the Controller Action
[HttpPost]
public
ActionResult AddToThirdPartyOpticsGoldList([DataSourceRequest] DataSourceRequest request, IEnumerable<SwitchModel> switchObjects, IEnumerable<ThirdPartyOpticsGoldListModel> goldListObjects)
{
TransceiverToSwitchReporting transceiverToSwitchReporting =
new
TransceiverToSwitchReporting(WebConfigurationManager.ConnectionStrings[
"DefaultConnection"
].ConnectionString);
var thirdPartyOpticsGoldListResult = transceiverToSwitchReporting.AddToThirdPartyOpticsGoldList(switchObjects, goldListObjects);
if
(!thirdPartyOpticsGoldListResult.Result)
{
ModelState.AddModelError(
"AddToThirdPartyOpticsGoldList"
, thirdPartyOpticsGoldListResult.Message);
}
return
Json(
new
[] { thirdPartyOpticsGoldListResult.Payload }.ToDataSourceResult(request, ModelState));
}
Any thoughts?