I would like to post the whole grid data even though it is not changed with additional value[Status: Approved or Rejected].
I can get the additional value in the controller but not the grid data. The grid data has been posted and it is available in the form collection but it is not been binded with the model using the attribute. [Bind(Prefix="updated")].
Code sample:
View
ApproveAll =
function() {
if (confirm('Are you sure you want to Approve All?')) {
var gridSample = $('#gSample').data('tGrid');
if (gridSample.hasChanges()) {
gridSample.submitChanges();
}
else {
var additionalValues = gridSample.data;
if (!$.telerik.trigger(gridAccount.element, 'submitChanges', { updated: additionalValues })) {
gridSample.sendValues({ inserted:
null, updated: additionalValues, deleted: null, data: "A" }, 'updateUrl', 'submitChanges');
}
return true;
}
Approve all - it is an input button on the page
<%Html.Telerik().Grid(Model)
.Name(
"gSample")
.DataKeys(keys => { keys.Add(p => p.ID);
keys.Add(key => key.SubmitTimeStamp).RouteKey(
"SubmitTimeStamp");
})
.ClientEvents(e => e.OnSave(
"approval.gSample_OnSave")
.OnDataBound(
"approval.gSample_OnDataBound")
.OnComplete(
"approval.gSample_OnComplete"))
.DataBinding(dataBinding => dataBinding.Ajax().OperationMode(
GridOperationMode.Client)
.Select(
"_getData", "Sample", new {type = type })
.Update(
"ApprovalAction", "Approval"))
.Columns(columns =>
{
columns.Bound(e => e.ID).Title(
"ID").Hidden();
columns.Bound(e => e.IDFormatted).Title(
"ID").ReadOnly(true);
columns.Bound(e => e.Name).Title(
"Name").ReadOnly(true);
if(user.IsApprover || user.IsDeveloper)
columns.Bound(e => e.ActionType).Width(120).HtmlAttributes(
new {style = "text-align:center"});//Editor template with telerik dropdownlist control [options : Approve/Reject/None]
})
.Resizable(c => c.Columns(
true))
.Editable(editing => editing
.Mode(
GridEditMode.InCell))
.Sortable()
.Footer(
false)
.HtmlAttributes(
new { style = "text-align:center" })
.ToolBar(commands => commands.Custom().HtmlAttributes(
new { id = "export" }).Text("Excel").Action("ExportToExcel", "Shared", new { page = 1, orderBy = "~", filter = "~", grid = "ACCNTAPPROVAL", param = "" })).HtmlAttributes(new { style = "text-align:right" })
.Render();
%>Controller:
[
GridAction]
[
AcceptVerbs(HttpVerbs.Post)]
public ActionResult ApprovalAction(
[
Bind(Prefix = "inserted")] IEnumerable<SampleBE> insertedData,
[
Bind(Prefix = "updated")] IEnumerable<SampleBE> updatedData,
[
Bind(Prefix = "deleted")] IEnumerable<SampleBE> deletedData,string data)
{
string error = string.Empty;
var records=new List<SampleBE>();
if (updatedData != null)
{
records= updatedData.ToList();
foreach (var record in records)
{
record.ActionType = (record.ActionType ==
"Approve") ? "A" : (record.ActionType == "Reject") ? "R" : "";
}
if (string.IsNullOrEmpty(error))
records= approvalBusController.DoApprovalAction(records, "",
ref error);
}
ModelState.AddModelError(
"Error", error);
return View( new GridModel(records));
}
updatedData param consist of collection of SampleBE with all null values for its properties. But the grid values are available in form collection with prefix "updated".
All I need is to have the whole grid data should be available in param "updatedData"
Thanks in advance.
Regards,
Louis