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

Destroy method not working?

4 Answers 1914 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scot
Top achievements
Rank 1
Scot asked on 10 Aug 2012, 02:35 PM
I am 100% sure that it is something that i am missing. I am just starting out with Kendo. But any help is appreciated.

I assumed that when i clicked the delete button in the grid that it would automatically send my request to a "destroy.cfm" file. I cannot see any action in firebug to show this.

Help a nOOb out.

Thanks alot!

$(document).ready(function () {
    $("#grid").kendoGrid({
        dataType: "json",
        dataSource: {
            transport: {
                read: "cfcs/queries.cfm",
                destroy: {
                   url: "/cfcs/destroy.cfm"
                }
             
            },
 
            schema: {
                data: "data",
                model: {
                    fields: {
                        BADGEID: {
                            type: "number"
                        },
                        EMPLOYEENAME: {
                            type: "string"
                        },
                        UNITID: {
                            type: "number"
                        },
                        UNITNAME: {
                            type: "string"
                        }
                    }
                }
            }
             
        },
         editable: { 
            destroy: true,
            update: false
        },
        height: 450,
        filterable: true,
        groupable: true,
        sortable: true,
        pageable: false,
        columns: [{
            field: "BADGEID",
            title: " ",
            width: 35,
            template: "<input type='checkbox' />"
        },{
            field: "BADGEID",
            title: "Badge Id"
        }, {
            field: "EMPLOYEENAME",
            title: "Employee Name"
        }, {
            field: "UNITID",
            title: "Unit Id"
        }, {
            field: "UNITNAME",
            title: "Unit Name"
        }, {
            command: "destroy",
            title: " ",
            width: 110 }
        ]
    });
});

4 Answers, 1 is accepted

Sort by
0
Scot
Top achievements
Rank 1
answered on 13 Aug 2012, 05:51 PM
I can do a crappy work around within the remove method of the grid but that is not the preferred method. Any ideas why it's not working?
remove: function(e) {
       $.ajax({
               url: '/cfcs/deleteCSR?id=' + e.model.BADGEID,
               success: function() {
                   alert("Success")
               }
           });

0
Abhishek
Top achievements
Rank 1
answered on 29 Aug 2012, 04:34 AM
Hi Scot,
Try to add unique ID within the model of DataSource as mentioned below. As for UPDATE and DELETE operation you would need unique value to perform the operation at database.

model: {
id: "BADGEID",
fields: {
...
}

Many Thanks,
Abhishek Shrotriya
0
Scot
Top achievements
Rank 1
answered on 29 Aug 2012, 01:29 PM
I did so many things that I am not sure what the fix was. I copied back the demo code from the site and started replacing their code with mine.  But I think what did the trick to get the delete event to fire was the addition of the editable: "inline" configuration.

 

$("#grid").kendoGrid({
                        dataSource: dataSource,
                        height: 400,
                        groupable: true,
                        sortable: true,
                       
                        columns: [{
                                field: "BADGEID",
                                title: "Badge Id"
                            },{
                                field: "EMPLOYEENAME",
                                title: "Employee Name"
                            },{
                                field: "SAMPLES",
                                title: "Samples"
                            },{
                                field: "UNITNAME",
                                title: "Unit Name"
                            },{
                                field: "COMMENT",
                                title: "Title"
                            },{
                                command: ["destroy"],
                                title: " ",
                                width: 110
                            }
                            ],
                        editable: "inline",
                        remove: function(e) {
                              
                            //grid.cancelChanges();
                            //e.preventDefault();
                            //console.log(e);
                        }
                    });
0
tony
Top achievements
Rank 1
answered on 18 Sep 2012, 05:18 PM
adding an id solved my instance of this problem....is it possible to indicate multiple columns as part of the id? there are cases where the table may not have a key and one needs to be imposed upon it. i tried different variations of syntax with no success.
Tags
Grid
Asked by
Scot
Top achievements
Rank 1
Answers by
Scot
Top achievements
Rank 1
Abhishek
Top achievements
Rank 1
tony
Top achievements
Rank 1
Share this question
or