
I'm using batch-mode and server-side operations. it looks like you do some special things in the parameterMap function (behind the scenes) when the operation == "read" and filtering is applied. For example, when a filter is applied to a column, it seems you put the filtering parameters in a special format before sending to the server. Even though I'm using the MVC wrappers, I can still wire-up the parameterMap feature using JavaScript. I did this for ONLY the "destroy" operation (I want to send just the IDs and not the models), but then the "read" operation no longer works when filtering is applied, because my use of parameterMap overwrites what you are doing for "read".
Can I still use the parameterMap feature for only "destroy", and not interfere with what you do with "read" ? My desire is to send just the IDs and not the models when batch-saving deletes.
5 Answers, 1 is accepted
Hello Curt,
Could you please share the implementation of the parameterMap you are using. This will allow us to provide you with more to-the-point suggestion. Generally speaking if have override the parameterMap you will need to call the base parameterMap when special transport is used. In such cased it will serialize the request parameters in the appropriate format for the special transport.
However, in order to achieve the described functionality using the ASP.NET MVC wrappers, you could use the Data function of the Destroy Action. There you could override the data send to the server. For example:
.DataSource(dataSource => dataSource
.Ajax()
.Destroy(destroy => destroy.Action(
"Editing_Destroy"
,
"Grid"
).Data(
"destroyData"
))
)
<script type=
"text/javascript"
>
function
destroyData(data) {
var
models = data.models;
for
(
var
idx = 0; idx < models.length; idx++) {
models[idx] = { ProductID: models[idx].ProductID };
}
}
</script>
Regards,
Rosen
Telerik

Thank you for the detailed response. However, I used your exact same code and yes, the function is called where you can overwrite the models making them have ONLY the model ID property, BUT when the data is received in the controller action, ALL of the model properties are still present for each model sent. I did try using .Data() for sending "extra" parameters which does work, but it seems your wrappers send a different copy of the models than those modified by .Data().
My setup:
@(Html.Kendo().Grid<Test_KendoMVC.Models.pn_ContractFees>()
.Name("pn_ContractFeesGrid")
.Columns(columns =>
{
columns.Bound(c => c.FeeTitle).Title("Fee Title");
columns.Bound(c => c.BaseCharge).Title("Base Charge");
columns.Bound(c => c.MinHours).Title("Min Hours");
})
.Scrollable(s => s.Enabled(true))
.Sortable()
.Filterable()
.Pageable(p => p.PageSizes(new[] { 15, 30, 50 }))
.ToolBar(tb => { tb.Create(); tb.Save(); })
.Editable(e =>
{
e.DisplayDeleteConfirmation(false);
e.Mode(GridEditMode.InCell);
})
.DataSource(ds => ds
.Ajax()
.Batch(true)
.PageSize(30)
.Model(model =>
{
model.Id(m => m.ContractFeeID);
})
.Create(a => a.Action("pn_ContractFeesGrid_Save", "ContractFees"))
.Read(a => a.Action("pn_ContractFeesGrid_Read", "ContractFees"))
.Update(a => a.Action("pn_ContractFeesGrid_Save", "ContractFees"))
.Destroy(a => a.Action("pn_ContractFeesGrid_Delete", "ContractFees"))
.Events(e => e
.RequestStart("function () { gridLib.utility.clearMessages(pn_ContractFeesGrid.grid); }")
.Error("function (e) { gridLib.utility.handleError(e, pn_ContractFeesGrid.grid); }")
)
)
)
function destroyData(data) {
var models = data.models;
for (var idx = 0; idx < models.length; idx++) {
models[idx] = { ContractFeeID: models[idx].ContractFeeID };
}
}
[HttpPost]
public ActionResult pn_ContractFeesGrid_Delete(pn_ContractFees[] models)
...when the pn_ContractFeesGrid_Delete action is called, the models parameter will have an array of models that were deleted in the grid, but those models will have ALL properties. I only need the main ID property for deleting.

Hello Curt Rabon,
You can call the default aspnetmvc-ajax parameterMap implementation in your own paramterMap similar to the following:
var
result = kendo.data.transports[
"aspnetmvc-ajax"
].prototype.options.parameterMap.call(
this
, options, type);
Rosen
Telerik
