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

Create being called when I click delete

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Padhraic
Top achievements
Rank 1
Padhraic asked on 03 Jul 2015, 03:42 AM

I have created a Kendo UI grid with inline editing, but when I click on the delete command my the create function of the data-source is called, not the delete function. There is probably just a simple problem with this grid but I cannot see it.

Here is my grid code.

 var grid = $("#grid").kendoGrid({
        sortable: true,
        groupable: false,
        scrollable: false,
        dataSource: {
            transport: {
                read: {
                    url: GetActionLink("RefCode", "", "", true),
                    dataType: "Json"
                },
                update: {
                    url: function(refcode) {
                        return GetActionLink("RefCode", "", refcode.Id, true);
                    },
                    type: "PUT"
                },
                destroy: {
                    url: function (refcode) {
                        return GetActionLink("RefCode", "", refcode.Id, true);
                    },
                    type: "DELETE"
                },
                create: {
                    url: function() {
                        GetActionLink("RefCode", "", "", true); //<====== break point is hit here when I click delete button ======================
                    },
                    type: "POST"
                }
            },
            schema: {
                model: {
                    id: "Value",
                    fields: {
                        Id: { type: "number", editable: false, nullable: false },
                        Type: { type: "number", nullable: false, validation: { required: true }},
                        Text: { type: "string", validation: { required: true }},
                        Order: { type: "number", validation: { required: true } }
                    }
                }
            },
            pageSize: 15
        },
        columns: [
            { field: "Type", title: "Type", width: 50, template: "#=GetLookupText(Type,RefCodeTypeData)#", editor: RefCodeTypeEditor, attributes: { style: "text-align: center;" } },
            { field: "Text", title: "Details", width: 50 },
            { field: "Order", title: "Order", width: 20, attributes: { style: "text-align: center;" } },
            { command: [{ name: "edit", text: "edit" }, { name: "destroy", text: "delete" }], title: "&nbsp;", width: 30 }
        ],
        pageable: {
            refresh: true,
            pageSizes: true,
            buttonCount: 5
        },
        editable: "inline"
    });
    

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 06 Jul 2015, 08:06 AM

Hello Padhraic,

Most probably the Id field is not set correctly. In the posted code snippet it seems that a field named Value is set as an Id field in the schema model declaration, however, in the URL construction field named Id is used instead. Therefore, I suspect that the schema model id should be set to Id instead of Value. Please try this change and see if this makes any difference in the observed behavior.

Regards,
Rosen
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
Padhraic
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or