Hi,
I'd like to invoke the batch edit controller method on delete. That is when the user deletes, besides the grid updating and removing the row, I want the record removed immediately as opposed to when the user clicks the *Save changes* button. To do it I want to call the batchedit controller action with jquery.
So I'm thinking in my telerik mvc grid I have this
.ClientEvents(eve => eve.OnDelete("Grid_onDelete"))
Then in jquery I have this
function Grid_onDelete(e) {
var item = e.dataItem;
var grid = $(this).data("tGrid");
var deleted_here = [];
deleted_here.push(item);
jQuery.ajaxSettings.traditional = true;
$.post('/MyController/_MySaveBatchEditingAction', { insertedList: null, updatedList: null, deletedList: $.param({ deletedList: deleted_here }), myextraparam: null }, true, function (result) {
var grid = $(this).data("tGrid");
grid.submitChanges();
grid.ajaxRequest();
$(".t-grid .t-refresh").trigger('click');
});
Now what's happening is although the above array, deleted_here, does have the correct value the controller action as defined below always gets a null value for deletedList.
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _MySaveBatchEditing([Bind(Prefix = "inserted")]IEnumerable<MyModel> insertedList,
[Bind(Prefix = "updated")]IEnumerable<MyModel> updatedList,
[Bind(Prefix = "deleted")]IEnumerable<MyModel> deletedList,string myextraparam)
So how do I pass the array, deleted_here, to the controller action, _MySaveBatchEditing, so deletedList is not null and in the proper format?
Thanks