batchUrl - Not triggered

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 ?







3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team October 27, 2017 03:20 PM UTC

Hi Jakob, 

Thanks for contacting Syncfusion support. 

We can reproduce the reported issue from our end. In your code example we found that you have bound the dataSource to the Grid as local data then it will act as locally. So, we suggest you to enable remotesaveAdaptor while updating dataSource to the Grid then we can do CRUD operations in server side itself. 

Refer the below code example. 


<script type="text/javascript"> 
        function changeWeek(args) { 
 
            --- 
 
            var promise3 = dataManager3.executeQuery(query3); 
 
            promise3.done(function (e) { 
 
                var gridObj3 = $("#FlatGrid").ejGrid("instance"); 
                gridObj3.dataSource(ej.DataManager({ 
 
                    json : e.result.result, 
                    batchUrl:"/Home/BatchUpdate", 
                    adaptor : new ej.remoteSaveAdaptor() 
 
                })); 
            }); 
        } 
         
    </script> 


We have prepared a sample and it can be downloadable from the below location. 


Refer the help documentation. 


Regards, 
Thavasianand S. 



JH Jakob Harper October 27, 2017 04:57 PM UTC

Perfect.

Code example was enough.

Thank you.



TS Thavasianand Sankaranarayanan Syncfusion Team October 30, 2017 04:03 AM UTC

Hi Jakob, 
 
We are happy that the problem has been solved at your end. 
 
Please get back to us if you need any further assistance.  
 
Regards, 
Thavasianand S. 
 


Loader.
Up arrow icon