Here is the scenario: I have a grid that is set to GridEditMode.InCell and Batch=true. I can make changes to up to 15 records in the grid, click save and the data posts back to the controller without issue. However, if I update greater than 15 records and click save, the postback to the controller works but the data is null.
I hope that this isn't a product limitation and I've verified that data being posted back is less than the limit of Json serializer.
A few caveats to my issue:
1. We have purchased the licensed version, but have not gone through internal channels to actually access the licensed version so I am still using the trial version. Is it possible that the trial version has a limitation like this?
2. The grid is a nested hierarchical grid and the data being updated is nested 3 deep.
3. While the grid doesn't display all the data, each record being posted back contains a nested json object (see example of data below). Because of configurable business requirements, the structure cannot be flat.
Any help would be appreciated. Specifically, knowing the save/update method in kendo code that is being called for batch saves with InCell mode.
Here is my grid (higher level nesting is omitted for simplicity):
<
script
id
=
"agents"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<
TLCAgentSchedulerShared.Models.AgentDailyScheduleModel
>
()
.Name("agent_#=Id#")
.Columns(columns =>
{
//columns.Command(command => { command.Destroy().Text(" "); }).Width(50);
columns.Command(command => { command.Destroy().Template("<
button
type
=
'button'
onclick
=
'removeAgent(this, setCoEId())'
class
=
'btn btn-danger btn-xs'
><
span
class
=
'glyphicon glyphicon-remove'
title
=
'Delete'
>X</
span
></
button
>").Text(" "); }).Width(50);
columns.Bound(b => b.FullName).Width(100).Title("Agent");
columns.Bound(b => b.Supervisor).Width(100).Title("Supervisor");
columns.Bound(b => b.TimeSlot).Width(50).Title("Schedule");
columns.Bound(b => b.AgentAssignments[0].IsAssigned).Width(70).Title("6:30AM - 8:30AM").EditorTemplateName("Boolean")
.ClientTemplate(@"<
input
type
=
'checkbox'
\\#: AgentAssignments[0].IsAssigned ?
checked
=
'checked'
: '' \\# />");
columns.Bound(b => b.AgentAssignments[1].IsAssigned).Width(70).Title("8:30AM - 3:00PM").EditorTemplateName("Boolean")
.ClientTemplate(@"<
input
type
=
'checkbox'
\\#: AgentAssignments[1].IsAssigned ?
checked
=
'checked'
: '' \\# />");
columns.Bound(b => b.AgentAssignments[2].IsAssigned).Width(70).Title("3:00PM - 5:00PM").EditorTemplateName("Boolean")
.ClientTemplate(@"<
input
type
=
'checkbox'
\\#: AgentAssignments[2].IsAssigned ?
checked
=
'checked'
: '' \\# />");
columns.Bound(b => b.AgentAssignments[3].IsAssigned).Width(70).Title("5:00PM - 7:30PM").EditorTemplateName("Boolean")
.ClientTemplate(@"<
input
type
=
'checkbox'
\\#: AgentAssignments[3].IsAssigned ?
checked
=
'checked'
: '' \\# />");
columns.Bound(b => b.AgentAssignments[0].Comments).Title("Comments").Width(195);
})
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.UserProfileId))
.Batch(true)
.Read(read => read.Action("GetDefaultAgentsByPod", "Grid").Data("setDayOfWeek(#=Id#)"))
.Update(update => update.Action("UpdateDefaultAgentsInPod", "Grid")).Events(events => events.Change("change_handler"))
//.Destroy(destroy => destroy.Action("RemoveDefaultAgentsInPod", "Grid").Data("setCoEId()")).Events(events => events.Change("change_handler"))
)
//.Pageable()
.HtmlAttributes(new { @class = "agentGrid" })
.ToolBar(toolbar =>
{
toolbar.Save();
toolbar.Custom().Text("Assign a New Agent").HtmlAttributes(new { onclick = "assignAgent(#=Id#)" });
})
.Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
.Sortable()
.ToClientTemplate()
)
</
script
>
Here is my controller that works fine when less than 15 records have been updated (some security logic has been omitted to avoid potential confidentiality issues), but the key is that both the request object and the agents object are fully populated when less than 15 records:
[HttpPost]
public async Task<
ActionResult
> UpdateDefaultAgentsInPod([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<
AgentDailyScheduleModel
> agents)
{
//Convert incoming to json
string jsonData = JsonConvert.SerializeObject(agents);
using (var client = new HttpClient())
{
using (var response = await client.PostAsync(String.Format("{0}agent/UpdateDefaultAssignmentsByPod/", _baseApiUrl),
new StringContent(jsonData, Encoding.UTF8, "application/json")))
{
string apiResponse = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<
ApiResponse
<List<AgentDailyScheduleModel>>>(apiResponse);
if (result.IsValid)
{
agentList = result.ResponseData;
}
else
{
return BadRequest(String.Format("There was an error proccessing your request. Message: {0}", result.ResponseMessage));
}
}
}
var dsResult = agentList.ToDataSourceResult(request);
return Json(dsResult);
}
Here is what 1 record of data looks like:
[{
"UserProfileId": 150,
"NtLogin": "xxxx",
"FullName": "xxxx",
"Supervisor": null,
"TimeSlot": "7:30-19:00",
"AgentAssignments": [{
"PodId": 2,
"PodName": "PODFREpat",
"DailyAssignmentId": 9070,
"AgentDefaultScheduleId": 12699,
"BlockId": 1,
"IsScheduled": true,
"IsAssigned": true,
"IsDefault": true,
"Date": null,
"IsBlockFullyScheduled": false,
"Comments": null,
"CreatedBy": null,
"UpdatedBy": null,
"CreatedOn": "0001-01-01T00:00:00",
"UpdatedOn": "0001-01-01T00:00:00"
},
{
"PodId": 2,
"PodName": "PODFRE-pat",
"DailyAssignmentId": 9071,
"AgentDefaultScheduleId": 12724,
"BlockId": 2,
"IsScheduled": true,
"IsAssigned": true,
"IsDefault": true,
"Date": null,
"IsBlockFullyScheduled": true,
"Comments": null,
"CreatedBy": null,
"UpdatedBy": null,
"CreatedOn": "0001-01-01T00:00:00",
"UpdatedOn": "0001-01-01T00:00:00"
}, {
"PodId": 2,
"PodName": "POD FRE-pat",
"DailyAssignmentId": 9072,
"AgentDefaultScheduleId": 12723,
"BlockId": 3,
"IsScheduled": true,
"IsAssigned": true,
"IsDefault": true,
"Date": null,
"IsBlockFullyScheduled": true,
"Comments": null,
"CreatedBy": null,
"UpdatedBy": null,
"CreatedOn": "0001-01-01T00:00:00",
"UpdatedOn": "0001-01-01T00:00:00"
}, {
"PodId": 2,
"PodName": "POD FRE-pat",
"DailyAssignmentId": 9050,
"AgentDefaultScheduleId": 12722,
"BlockId": 4,
"IsScheduled": true,
"IsAssigned": true,
"IsDefault": true,
"Date": null,
"IsBlockFullyScheduled": false,
"Comments": null,
"CreatedBy": null,
"UpdatedBy": null,
"CreatedOn": "0001-01-01T00:00:00",
"UpdatedOn": "0001-01-01T00:00:00"
}
]
}]