Problem: additional data not being sent to my delete action when added to data collection of OnCommand event argument.
Scenario: I have a grid displaying a List<Project>. My Project class's properties include ID (type guid) and State (type integer). When I click Delete on a row the ID is correctly being sent to my _Delete ajax action.
I also want to send my State integer. It is not being sent to the action despite seemingly following the Telerik method published here: http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-client-api-and-events.html#OnCommand
Here's the relevant snippets from my grid:
.DataBinding(dataBinding => dataBinding
.Ajax()
.Delete("_Delete", "Project"))
…columns.Command(commands =>
{
commands.Delete()
.ButtonType(GridButtonType.Image);
});
…
.ClientEvents(events => events
.OnCommand("onCommand")
)
And here's how I'm handling the OnCommand event:
function onCommand(e)
{
if (e.name == "delete")
{
// pass entity state so server action can toggle between Archive / Restore
e.data = $.extend(e.data, {
state: e.dataItem.State
});
}
}
When i debug I can see the OnCommand event fires and e.Data gets the state correctly added.
However State never reaches the server. Using Fiddler2 to watch the traffic I can see that the id is being sent but my State integer is not.
Am I missing a step. Is Telerik sure that the e.data collection is being included in the ajax call?
Regards
Phil