Thanks, the code works just fine. I have another question, previously I was using the inline edit mode in the Grid and when I was performing the save action through the endEdit function, I update also another Grid in my page whith the data that was updated in the current Grid. This is the code I was using:
@(Html.EJ().Grid<InvoiceData>("PendingInvoices")
.Datasource(ds => ds.Json((IEnumerable<InvoiceData>)ViewBag.Facturas).BatchURL("BatchUpdateInvoices").Adaptor(AdaptorType.RemoteSaveAdaptor))
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Batch).ShowConfirmDialog(false); })
.CssClass("CustomCss")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
toolbar.ShowToolbar(true).CustomToolbarItems(new List<object>() { "Collapse" });
})
.AllowTextWrap()
.AllowGrouping()
.GroupSettings(group => { group.ShowDropArea(false).GroupedColumns(col => { col.Add("Cliente"); }); })
.ShowSummary()
.SummaryRow(row =>
{
row.ShowCaptionSummary(true)
.ShowTotalSummary(false)
.SummaryColumns(col =>
{
col.SummaryType(SummaryType.Sum)
.Format("{0:C}")
.DisplayColumn("BalanceRemainingHomeCurrency")
.DataMember("BalanceRemainingHomeCurrency")
.Add();
}).Add();
row.TitleColumn("Cliente").Title("Total:").SummaryColumns(col =>
{
col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("BalanceRemainingHomeCurrency").DataMember("BalanceRemainingHomeCurrency").Add();
col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("BalanceRemaining").DataMember("ForeignOpenBalance").Add();
}).Add();
})
.Columns(col =>
{
col.Field("Empresa").Visible(false).Add();
col.Field("Unidad").Visible(false).Add();
col.Field("Year").Visible(false).Add();
col.Field("SemDesde").Visible(false).Add();
col.Field("SemHasta").Visible(false).Add();
col.Field("CambioUSD").Visible(false).Add();
col.Field("CambioEUR").Visible(false).Add();
col.Field("ForeignOpenBalance").Format("{0:C}").Visible(false).Add();
col.Field("Id").IsPrimaryKey(true).Visible(false).Add();
col.Field("Cliente").HeaderText("Cliente").Width(31).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("RefNumber").HeaderText("Factura").Width(29).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("TxnDate").HeaderText("Fecha").Width(26).TextAlign(TextAlign.Center).Format("{0:dd/MM/yyyy}").AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("DueDate").HeaderText("Vence").Width(28).TextAlign(TextAlign.Center).Format("{0:dd/MM/yyyy}").AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("Terms").HeaderText("Terms").Width(26).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("Class").HeaderText("Unidad de negocio").Width(45).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("BalanceRemaining").HeaderText("Importe").Width(38).TextAlign(TextAlign.Center).AllowEditing(false).Format("{0:C}").CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("Currency").HeaderText("Moneda").Width(33).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("ExchangeRate").HeaderText("Cambio").Width(30).TextAlign(TextAlign.Center).Format("{0:C}").AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("BalanceRemainingHomeCurrency").Width(43).HeaderText("Importe MXN").Priority(2).TextAlign(TextAlign.Center).Format("{0:C}").AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("Clasificacion").HeaderText("Clasificación").Width(41).TextAlign(TextAlign.Center).EditType(EditingType.Dropdown).DataSource((List<object>)ViewData["Clasificacion"])/*.DataSource((IEnumerable<object>)ViewData["DropDownSource"])*/.CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("Memo").HeaderText("Memo").Priority(1).Width(32).TextAlign(TextAlign.Justify).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Right).Add();
col.Field("Aging").HeaderText("Días atraso").Width(30).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("SemanaCalculada").HeaderText("Semana calculada").Width(34).TextAlign(TextAlign.Center).AllowEditing(false).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("SemanaCompromiso").HeaderText("Semana compromiso").Width(41).TextAlign(TextAlign.Center).EditType(EditingType.Numeric).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("AnnoCobro").HeaderText("Año").Width(25).TextAlign(TextAlign.Center)/*.EditType(EditingType.Numeric)*/.CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
col.Field("ObservacionesCobranza").HeaderText("Comentarios").TextAlign(TextAlign.Center).Width(42).EditType(EditingType.String).CssClass("myHeader").HeaderTextAlign(TextAlign.Left).Add();
})
.Mappers(map => map.ExportToExcelAction(@Url.Action("ExcelExportInvoices")))
.ClientSideEvents(eve => { eve.DataBound("dataBound").ActionBegin("begin").BeginEdit("edit").EndEdit("endEdit").ToolbarClick("OnToolbarClick").RecordClick("click"); })
)
<script>
function endEdit(args) {
$.ajax({
type: "GET",
url: "/InfoFinanciera/TotalesInvoiceUpdate", //TotalesInvoiceUpdate is Server side method
data: args.data,
dataType: "json",
success: function (data) {
//var genData = ej.DataManager({ json: data, updateUrl: "TotalesUpdate", adaptor: "remoteSaveAdaptor" })
var gridObj = $("#Totales").ejGrid("instance");
gridObj.dataSource(data);// Datasource bind to grid
}
});
$("#PendingInvoices").ejWaitingPopup("hide");
//collapse all groups except de editing one
this.collapseAll();
var collapse = this.element.find(".e-recordpluscollapse");
for (var i = 0 ; i < detailRows.length ; i++) {
for (var j = 0 ; j < collapse.length ; j++) {
if ($(collapse[j]).siblings().text() == $(detailRows[i]).siblings().text())
this.expandCollapse($(collapse[j]).children());
}
}
}
</script>
Want I want now is to perform the same update in the other Grid, but this time I need to obtain the list of updated rows to pass this data to the server method. Previously, like is shown in the code I was using args.data to refer the update row.