Delete not being called

3 posts, 1 answers
  1. RES
    RES avatar
    77 posts
    Member since:
    Sep 2010

    Posted 27 Oct 2014 Link to this post

    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. Answer
    Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 29 Oct 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. RES
    RES avatar
    77 posts
    Member since:
    Sep 2010

    Posted 29 Oct 2014 in reply to Rosen Link to this post

    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.
Back to Top