This is a migrated thread and some comments may be shown as answers.

[Solved] Sending additional parameters to Grid.DataSource.Destroy

3 Answers 778 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wim
Top achievements
Rank 1
Wim asked on 10 Oct 2014, 06:50 AM
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:
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: 0
07.    };
08. 
09.    if (data !== null) {
10.        obj.OntvangstId = data.OntvangstId;
11.    }
12. 
13.    return obj;
14.}

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 14 Oct 2014, 07:33 AM
Hi Wim,

I have tested sending additional parameters to the .Destroy() using .Data() and it worked as expected. Please check the following screencast:

http://www.screencast.com/t/exQDdUuhVD

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wim
Top achievements
Rank 1
answered on 17 Oct 2014, 06:54 AM
I've followed it step-by-step again, and it is working now. I am not sure where it went wrong.

Thank you for your reply!
0
Kiril Nikolov
Telerik team
answered on 17 Oct 2014, 10:09 AM
Hello Wim,

Glad I helped.

In case you have any further questions,please do not hesitate to contact us.


Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Wim
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Wim
Top achievements
Rank 1
Share this question
or