I've been struggling with deleting a record from a grid view all weekend. I could really use some assistance.
Below is my code:
01.var documentDataSource = new kendo.data.DataSource({02. transport: {03. read: { url: "/api/MedicalNecessityReviewAPI/GetDocumentsByAuthID", data: function () { return []; } }04. , create: { url: "/api/MedicalNecessityReviewAPI/AddDocument", data: function () { return []; } }05. , delete: {06. url: '/api/MedicalNecessityReviewAPI/DeleteMedReviewDocument'07. , data: { DocID: $("DocID").val(), UserID: $("UserID").val() }08. , dataType: "jsonp"09. , type: "GET"10. }11. , dataType: "jsonp"12. 13. , parameterMap: function (options, operation) {14. if (operation !== "read" && options.models) {15. return { models: kendo.stringify(options.models) };16. }17. }18. }19. , serverPaging: false20. , serverSorting: false21. , serverFiltering: false22. , pageSize: 2523. , schema: {24. // total is returned in the "total" field of the response;25. total: "total"26. , data: "results"27. }28.});29. 30.// search results kendo grid31.$("#documentGrid").kendoGrid({32. autoBind: true33. , height: 40034. , sortable: false35. , pageable: { buttonCount: 5 }36. , filterable: false37. , selectable: false38. , columnMenu: false39. , noRecords: { template: kendo.template($("#EmptyGridMessage").html()) }40. , columns: [41. { field: "originalFilename", title: "File Name", width: "60%" }42. , { field: "lastUpdatedDate", title: "Uploaded Date", template: "#= kendo.toString(kendo.parseDate(lastUpdatedDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #" }43. //, { field: "docId", title: "DocId" }, { field: "authId", title: "AuthId" }, { field: "docData", title: "DocData" }, { field: "docExtension", title: "DocExtension" }, { field: "deleted", title: "Deleted" }, { field: "userId", title: "UserId" }44. , { command: ["Delete"], title: " ", width: "100px" }45. ]46. , dataSource: documentDataSource,47.});Any assistance would appreciated!
6 Answers, 1 is accepted
Here is where I am at this point:
01.// Documents datasource02.var documentDataSource = new kendo.data.DataSource({03. transport: {04. read: { url: "/api/MedicalNecessityReviewAPI/GetDocumentsByAuthID", data: function () { return []; } }05. , create: { url: "/api/MedicalNecessityReviewAPI/AddDocument", data: function () { return []; } }06. , destroy: {07. url: '/api/MedicalNecessityReviewAPI/DeleteMedReviewDocument'08. , data: { DocID: $("#DocID").val(), UserID: $("#UserID").val() }09. , dataType: "jsonp"10. , type: "POST"11. }12. , dataType: "jsonp"13. , parameterMap: function (options, operation) {14. if (operation !== "read" && options.models) {15. return { models: kendo.stringify(options.models) };16. }17. }18. }19. , serverPaging: false20. , serverSorting: false21. , serverFiltering: false22. , pageSize: 2523. , schema: {24. total: "total"25. , data: "results"26. , model: {27. docId: { editable: false, nullable: true }28. }29. }30.});31. 32.// documents kendo grid33.$("#documentGrid").kendoGrid({34. autoBind: true35. , columns: [36. { field: "docID", hidden: true }37. , { field: "originalFilename", title: "File Name", width: "60%" }38. , { field: "lastUpdatedDate", title: "Uploaded Date", template: "#= kendo.toString(kendo.parseDate(lastUpdatedDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #" }39. , { field: "docId", title: "DocId" }//, { field: "authId", title: "AuthId" }, { field: "docData", title: "DocData" }, { field: "docExtension", title: "DocExtension" }, { field: "deleted", title: "Deleted" }, { field: "userId", title: "UserId" }40. , { command: "destroy" }41. , { template: "<a href='/api/MedicalNecessityReviewAPI/DocViewer?DocID=#= docId #'>View</a>", title: " " }42. ]43. , columnMenu: false44. , dataSource: documentDataSource//, schema: {model: {id: "id"}}45. , editable: "inline"46. , filterable: false47. , height: 40048. //, toolbar: ["edit", "save", "cancel"]49. //, messages: { commands: { save: "Save changes" } }50. , noRecords: { template: kendo.template($("#EmptyGridMessage").html()) }51. , pageable: { buttonCount: 5 }52. , selectable: false53. , sortable: false54.});
It is now hitting my ADD API. I read somewhere else that the cause is because the ID is not being passed so it things it is a new record and wants to process under the "create". This to me is bad Telerik logic, but I'm STILL looking for a fix.
Here is where I am at this point. When I click "delete" it is asking me to verify that I want to delete and then it is calling the "create" and hitting the API. I read somewhere that this is because there is no data being passed. Below is the code at this point:
01.// Documents datasource02.var documentDataSource = new kendo.data.DataSource({03. transport: {04. read: { url: "/api/MedicalNecessityReviewAPI/GetDocumentsByAuthID", data: function () { return []; } }05. , create: { url: "/api/MedicalNecessityReviewAPI/AddDocument", data: function () { return []; } }06. , destroy: {07. url: '/api/MedicalNecessityReviewAPI/DeleteMedReviewDocument'08. , data: { DocID: $("#DocID").val(), UserID: $("#UserID").val() }09. , dataType: "jsonp"10. , type: "POST"11. }12. , dataType: "jsonp"13. , parameterMap: function (options, operation) {14. if (operation !== "read" && options.models) {15. return { models: kendo.stringify(options.models) };16. }17. }18. }19. , serverPaging: false20. , serverSorting: false21. , serverFiltering: false22. , pageSize: 2523. , schema: {24. total: "total"25. , data: "results"26. , model: {27. docId: { editable: false, nullable: true }28. }29. }30.});31. 32.// documents kendo grid33.$("#documentGrid").kendoGrid({34. autoBind: true35. , columns: [36. { field: "docID", hidden: true }37. , { field: "originalFilename", title: "File Name", width: "60%" }38. , { field: "lastUpdatedDate", title: "Uploaded Date", template: "#= kendo.toString(kendo.parseDate(lastUpdatedDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #" }39. , { field: "docId", title: "DocId" }//, { field: "authId", title: "AuthId" }, { field: "docData", title: "DocData" }, { field: "docExtension", title: "DocExtension" }, { field: "deleted", title: "Deleted" }, { field: "userId", title: "UserId" }40. , { command: "destroy" }41. , { template: "<a href='/api/MedicalNecessityReviewAPI/DocViewer?DocID=#= docId #'>View</a>", title: " " }42. ]43. , columnMenu: false44. , dataSource: documentDataSource//, schema: {model: {id: "id"}}45. , editable: "inline"46. , filterable: false47. , height: 40048. //, toolbar: ["edit", "save", "cancel"]49. //, messages: { commands: { save: "Save changes" } }50. , noRecords: { template: kendo.template($("#EmptyGridMessage").html()) }51. , pageable: { buttonCount: 5 }52. , selectable: false53. , sortable: false54.});
I could really use some assistance on this.
I know that no one has touched this yet, but just so others might find some help, I'm currently getting into the destroy API but I'm not getting my values passed though. Can someone help a brother out? Here is the code as it currently stands:
01.// Documents datasource02.var documentDataSource = new kendo.data.DataSource({03. transport: {04. read: { url: "/api/MedicalNecessityReviewAPI/GetDocumentsByAuthID", data: function () { return []; } }05. , create: { url: "/api/MedicalNecessityReviewAPI/AddDocument", data: function () { return []; } }06. , destroy: {07. url: '/api/MedicalNecessityReviewAPI/DeleteMedReviewDocument'08. , data: { docID: 8, userID: 221317 }09. //, data: { DocID: $("#DocID").val(), UserID: $("#UserID").val() }10. , dataType: "jsonp"11. , type: "POST"12. }13. , dataType: "jsonp"14. , parameterMap: function (options, operation) {15. if (operation !== "read" && options.models) {16. return { models: kendo.stringify(options.models) };17. }18. }19. }20. , serverPaging: false21. , serverSorting: false22. , serverFiltering: false23. , pageSize: 2524. , schema: {25. total: "total"26. , data: "results"27. , model: {28. id: "docId"29. , fields: {30. docId: { editable: false, nullable: true }31. , originalFilename: { editable: true, nullable: true }32. , lastUpdatedDate: { editable: false, nullable: true }33. }34. }35. }36.});37. 38.// documents kendo grid39.$("#documentGrid").kendoGrid({40. autoBind: true41. , columns: [42. { field: "docID", hidden: true }43. , { field: "originalFilename", title: "File Name", width: "60%" }44. , { field: "lastUpdatedDate", title: "Uploaded Date", template: "#= kendo.toString(kendo.parseDate(lastUpdatedDate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #" }45. , { field: "docId", title: "DocId" }//, { field: "authId", title: "AuthId" }, { field: "docData", title: "DocData" }, { field: "docExtension", title: "DocExtension" }, { field: "deleted", title: "Deleted" }, { field: "userId", title: "UserId" }46. , { command: "destroy" }47. , { template: "<a href='/api/MedicalNecessityReviewAPI/DocViewer?DocID=#= docId #'>View</a>", title: " " }48. ]49. , columnMenu: false50. , dataSource: documentDataSource//, schema: {model: {id: "id"}}51. , editable: "inline"52. , filterable: false53. , height: 40054. , noRecords: { template: kendo.template($("#EmptyGridMessage").html()) }55. , pageable: { buttonCount: 5 }56. , selectable: false57. , sortable: false58.});I really hope this helps someone else because not a single person helped me! Very disappointed.
So here is how we got it to work....
url: '@Url.Action("DeleteMedReviewDocument", "MedicalNecessityReviewAPI", new { docID=8, userID=221317 })'
I will post my completed code, so someone else can find sanity in my insanity, when I have the other things working correctly.
I'm sorry to hear that you are disappointed by the response time.
Please have in mind that our forums do not have a set response time as the support tickets(24 hours Mon-Fri):
http://www.telerik.com/purchase/support-plans/devtools
We usually try to respond to them within 2 business days, but we had a national holiday yesterday and we worked on a smaller capacity.
I hope that in the future we will provide faster response to the questions.
Still, if the issue is urgent I can suggest submitting a support ticket as the response time is usually twice as fast as the forum posts.
Regards,
Stefan
Progress Telerik
