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

Delete not being called

2 Answers 357 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RES
Top achievements
Rank 1
RES asked on 27 Oct 2014, 07:31 PM
I'm having a problem with deleting records from a simple list with only one field.  The UI works fine and deletes the record however the destroy call as defined in my datasources is not being called.  Here is the code.

var ds = new kendo.data.DataSource({
    transport: {
        read: {
            url: "/api/admin/users/someUser/roles",
            dataType: "json"
        },
 
        destroy: {
            type: "DELETE",
            url: "/api/admin/users/someUser/roles",
            dataType: "json"
        }
    },
 
    schema: {
        model: {
            id: "roleName",
            fields: {
                roleName: { editable: false }
            }
        }
    }
});
 
$grid.kendoGrid({
    dataSource: ds,
    editable: true,
    columns: [
        { field: 'roleName', title: 'Role' },
        { command: ['destroy'], title: ' ', width: '120px' }
    ]
});

Does the ID as defined in my model's schema have to be an integer or are strings acceptable?

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 29 Oct 2014, 12:02 PM
Hi,

As you know the default edit mode of the grid is incell. In this mode the changes made to the DataSource data are submitted when a separate 'save changes' button is clicked. Therefore, in the setup shown in the pasted code snippet, clicking the delete button does not submit the changes but waits the 'save changes' button click - a button which is not defined at all in this declaration. In order to achieve what you are looking a more appropriate edit mode will be inline. In this case the delete button will automatically trigger the DataSource sync - submitting the deleted record to the server.

$grid.kendoGrid({
    dataSource: ds,
    editable: "inline",
    columns: [
        { field: 'roleName', title: 'Role' },
        { command: ['destroy'], title: ' ', width: '120px' }
    ]
});


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
RES
Top achievements
Rank 1
answered on 29 Oct 2014, 04:03 PM
I ended up just using creating a table with an item template with a delete button on each row, but good to know for future reference.
Tags
Grid
Asked by
RES
Top achievements
Rank 1
Answers by
Rosen
Telerik team
RES
Top achievements
Rank 1
Share this question
or