I have a DropDownList changing the content of my Grid used for BatchMode editing.
Sniplets below.
DropDown:
@Html.EJ().DropDownList("selectWeek").Width("150px").Height("30px").ClientSideEvents(evt => evt.Change("changeWeek")).Datasource((List)ViewBag.WeekDropDown).Value(ViewBag.Week)
Grid:
@(Html.EJ().Grid<object>("SubscriptionGrid")
.Datasource(ds => ds.URL("IndexBatch").BatchURL("BatchUpdate").Adaptor(AdaptorType.UrlAdaptor))
.EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Batch); })
.ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Update); items.AddTool(ToolBarItems.Cancel); }); })
.ShowColumnChooser()
.AllowSorting()
.AllowPaging()
.IsResponsive()
.AllowSelection()
.AllowScrolling()
.AllowReordering()
.AllowResizing()
.AllowResizeToFit()
.ScrollSettings(col => { col.Width("auto").Height("auto"); })
.PageSettings(p => { p.PageSize(1000); })
.ContextMenuSettings(contextMenu => { contextMenu.EnableContextMenu(); })
.Columns(col =>
{
col.Field("NextInvoiceWeek").HeaderText("Faktura Uge").TextAlign(TextAlign.Right).AllowEditing(false).Width(75).Visible(true).EditType(EditingType.NumericEdit).Add();
col.Field("NextShipmentWeek").HeaderText("Test Uge").TextAlign(TextAlign.Right).AllowEditing(false).Width(75).Visible(true).EditType(EditingType.NumericEdit).Add();
col.Field("NewInvoiceWeek").HeaderText("Næste Fakt. Uge").TextAlign(TextAlign.Right).AllowEditing(true).Width(75).Visible(true).EditType(EditingType.NumericEdit).Add();
col.Field("NewShipmentWeek").HeaderText("Næste Test Uge").TextAlign(TextAlign.Right).AllowEditing(true).Width(75).Visible(true).EditType(EditingType.NumericEdit).Add();
}
)
Javascript:
function changeWeek(args) {
var WeekVal = $('#selectWeek').data("ejDropDownList");
var WeekValues = args.value;
$('input#HiddenWeek').val(WeekValues);
var dataManager3 = ej.DataManager({ url: "/Subscription/IndexBatch", adaptor: new ej.UrlAdaptor(), batchUrl: ("/Subscription/BatchUpdate") });
var query3 = ej.Query().where("NextShipmentWeek", "equal", WeekValues);
var promise3 = dataManager3.executeQuery(query3);
promise3.done(function (e) {
var gridObj3 = $("#SubscriptionGrid").ejGrid("instance");
gridObj3.dataSource(e.result.result);
});
}
If I change the data using the DropDownList/Javascript, the data/grid is udpated correct but the BatchURL is not triggered when I wish to save the data. I have tried different ways, but am I missing something in the Javascript to set the batchUrl again ?