I'm using a basic Kendo Grid with a WebApi data source. The calls to Create, Read and Update work just fine, even with additional data through .Data(), using a JavaScript function. However, when I try to do the same for the Delete call, it won't reach the method. The problem is, our DBA has not created a unique key for the rows I'm working with - I only have a composite key, which is why I need two values. Note that when I remove the additional parameter and additional data, the Delete action is called.
How do I achieve this?
The WebApi Delete method:
The Destroy() on the DataSource:
And finally, the JavaScript getSelectedReceiptId function:
How do I achieve this?
The WebApi Delete method:
1.public void Delete(int id, long receiptId)2.{3. service.Delete(receiptId, id);4.}The Destroy() on the DataSource:
1..Destroy(c => 2. c.Url(Url.HttpRouteUrl(3. "DefaultApi",4. new { controller = "ReceiptLines",5. id = "{0}" })6. ).Data("getSelectedReceiptId"))And finally, the JavaScript getSelectedReceiptId function:
01.function getSelectedOntvangstId() {02. var gridOntvangsten = $("#GridOntvangsten").data("kendoGrid");03. var selectedRow = gridOntvangsten.select();04. var data = gridOntvangsten.dataItem(selectedRow);05. var obj = {06. OntvangstId: 007. };08. 09. if (data !== null) {10. obj.OntvangstId = data.OntvangstId;11. }12. 13. return obj;14.}