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

transport.destroy of Grid Editor is not working

8 Answers 695 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammed Nazrul
Top achievements
Rank 1
Mohammed Nazrul asked on 19 Dec 2012, 11:26 AM
Hello Every one,

When We click the delete button it deletes the row on the fly. But it does not send any data by the transport.destroy {}  function to the server nor transport.destroy function to call delete action to remove from Database. How can I make it workable  (invoke deleteAction) through transport.destroy {} to delete data from server by {command : 'destroy' } Button?

For you convenience, here is my Code for your reviewing : 
===================================================

$("#grid").kendoGrid({                       
                        dataSource: {
                            type: "json",
                            serverPaging: true,
                            serverFiltering: false,
                            serverSorting: true,
                            batch: false,
                            pageSize: 10,
                            sort: { field: "image_date", dir: "desc" },
                            schema: {
                                data: 'data',
                                total: 'total',                           
                                model: {
                                    id: "image_file_name",
                                    fields: {
                                        image_field: { type: "string"/*, editable: false*/ },
                                        image_file_name: { type: "string" },
                                        image_file_size: { type: "numbers" },
                                        image_date: { type: "string" }
                                    }
                                }
                            },
                            error: function (e) {
                                 var json = jQuery.parseJSON(e.responseText);
                                 alert("An error has occured: " + json.Message);
                            },
                            transport: {                               
                                read: {
                                    type: "POST",
                                    dataType: "json",                               
                                     url: "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'grid'), 'adminrout',    true) ?>",
                                    data : <?php echo $this->settings_json_info; ?>,
                                    complete: function(e) {
                                        //alert(e.responseText.toSource());                                       
                                    }
                                },
                                destroy: {
                                    type: "GET",
                                    dataType: "json",
                                    cache: false,
                                    url: "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'delete'), 'adminrout',    true) ?>",
                                    data : <?php echo $this->settings_json_info; ?>,
                                    complete: function(e) {
                                        alert(e.responseText.toSource());
                                    }
                                },                               
                                 
                            }
                        },
                        selectable: "multiple",
                        change: OnChange,
                        height: 280,
                        filterable: true,
                        pageable: {
                            refresh: true,
                            pageSizes: true
                        },
                        scrollable:  {
                            virtual: true
                        },
                        sortable: true,
                        reorderable: true,
                        resizable: true,
                        columns: [                           
                            { field: "image_field", title: "Images", width: 50, template: '<img src="<?php echo $this->serverUrl().$this->baseUrl();  ?>/${ image_field }" height="60" />' },
                            { field: "image_file_name", title: "Name", width: 200},
                            { field: "image_file_size", title: "Size", width: 100},
                            { field: "image_date", title:"Date", width: 100},
                            { command: {
                                    name: "destroy",
                                    text: "Delete"
                              },
                              title: " ",
                              width: 100
                            }
                        ],                       
                        editable: { //disables the deletion functionality
                                 update: false,
                                 destroy: true
                              }
                    });   

According to the above code, the Delete Button does not invoke our PHP deleteAction() and i need your help.

 

8 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 20 Dec 2012, 08:08 AM
Hello Mohammed,

The deleted items will be automatically processed through transport destroy only for "inline"/"popup" edit modes.

The default edit mode is "incell"  and this the current mode in your grid implementation. To change that you must have the following grid configuration:
editable: {
..
mode: "inline",
...
}
//or
editable: "inline"


All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mohammed Nazrul
Top achievements
Rank 1
answered on 20 Dec 2012, 09:48 AM
Thanks Dear. 

It worked :)

 

0
Mohammed Nazrul
Top achievements
Rank 1
answered on 20 Dec 2012, 10:26 AM
Dear Sir, 

Could you please advice where can we find this parameter's documents and param list info in details to play with ?


 
0
Nikolay Rusev
Telerik team
answered on 20 Dec 2012, 11:01 AM
Hello Mohammed,

This article is good place to start: http://docs.kendoui.com/api/web/grid#editable-booleanobject-default

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mohamed
Top achievements
Rank 1
answered on 30 Oct 2015, 08:29 PM

Hi guys,

 

Currently I have this problem when trying to delete a record from a Kendo grid.

I have an id field in the model, the editable is set to "inline" and I'm not setting the batch button.

 what happens, is that the Create is being fired before the edit, so basically, the record is added to the database again before getting deleted.

I tried to debug and noticed the following:

As soon as I hit the Delete button (from the grid), the row is removed from the grid, then the create fire (I assume because now row was found in the data bound event) and then the deleted gets fired.

 

Any idea about this?

 

Thanks,

0
Nikolay Rusev
Telerik team
answered on 03 Nov 2015, 07:49 AM

Hello Mohamed,

 

This might happen if you haven't configured schema.model.id in the DataSource. The model will be considered as new in this case and on sync will be send to server through create action.

 

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mohamed
Top achievements
Rank 1
answered on 03 Nov 2015, 02:14 PM

Thanks Nikolay,

 As I said the id was configured but I found out that there was a data issue where one record had an empty id (the id field was auto generated but wasn't set as a primary key).

 

Thanks for your help,

0
Nikolay Rusev
Telerik team
answered on 04 Nov 2015, 12:15 PM

Hello Mohamed,

 

Each model must have unique value for the id field and that value must be different from the default value for the type of the field (for number - 0, for string - "").

 

Otherwise the model will be considered as new from the DataSource and when you sync it will be send through the create transport method.

 

You can verify whether a model is considered new or not by inspecting the return value of isNew method.

 

Regards,
Nikolay Rusev
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
Mohammed Nazrul
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Mohammed Nazrul
Top achievements
Rank 1
Mohamed
Top achievements
Rank 1
Share this question
or