0

Here is my grid:

$("#category-gridview").kendoGrid({
     dataSource: {
         type: "json",
         transport: {
             read: {
                 url: function (options) {
                     return '/Product/GetCategories?id=' + $("#selectedProductId").val() + '&company=' + $("#company-dropdown").val() + '&language=' + $("#country-dropdown").val();
                 },
                 dataType: "json",
                 type: "POST"
             },
             destroy: {
                 url: '/Product/DeleteProductCategory',
                 dataType: "json",
                 type: "POST",
                 contentType: "application/json"
             },
             parameterMap: function (options, operation) {
                 console.log("HÄÄR");
                 console.log(options);
                 if (operation !== "read" && options.models) {
                     return JSON.stringify({
                         category: options
                     });
                 }
             }
         },
         schema: {
             model: {
                 fields: {
                     id: {
                         type: "string"
                     },
                     name: {
                         type: "string"
                     },
                 }
             }
         },
     },
     columns: [{
         field: "id",
         hidden: true

     }, {
         field: "name",
         title: "Category",
         width: "30px"
     }, {
         command: "destroy",
         title: " ",
         width: 15
     }],
     editable: false,
 });

somehow the read function works as expected but when i press the delete button i won't even reach my parameter map function. When i look in chrome console there is no request sent to my controller.

here is my controller method:

[HttpPost]
public JsonResult DeleteProductCategory(CategoryResponse category)
{
    return Json(category);
}
3
  • Maybe try removing the type: 'json' (according to the documentation docs.telerik.com/kendo-ui/api/javascript/data/…, that isn't a valid setting for dataSource.type) Commented Jun 30, 2015 at 12:39
  • thanks! But that didn't help :( Commented Jun 30, 2015 at 12:43
  • Oh, I think you need to return something in the parameterMap function for when the operation is destroy. Commented Jun 30, 2015 at 13:16

2 Answers 2

0

Let me try to answer, but to note that i change your transport and the column setting to match the field using kendo because obviously i can't use yours. Similar to this

transport: {
             read: {
                 url: "http://demos.telerik.com/kendo-ui/service/products",
                 dataType: "jsonp"
             },
             destroy: {
                 url: "http://demos.telerik.com/kendo-ui/service/products/destroy",
                    dataType: "jsonp"
             },
             parameterMap: function(options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
}, 
  • At first glance i notice you use "POST" on read and delete call, actually you don't need them?

But then you said that you couldn't reach the parametermap, i came to think of

  • You set editable : false, how can you edit it if you set it to false? you should make it to editable : true(note: also you can try to set it to false and then you can see the delete function will not work)

DEMO

Sign up to request clarification or add additional context in comments.

Comments

0

Instead of stringifing {param:value} Simply stringify value i.e stringify(options.models) for parameter category

parameterMap: function(options, operation) {
                                if (operation !== "read" && options.models) {
                                    return { category: kendo.stringify(options.models) };
                                }
                            }

1 Comment

Perhaps you should edit your answer to include a description how this answers the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.