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

Delete last row in the grid

2 Answers 716 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Guillermo
Top achievements
Rank 1
Guillermo asked on 28 May 2013, 10:30 PM
Hi Team,

When i am deleting the last row of a grid i need to fire some even. Can you please suggest how can i fire an event in the grid when the rows is getting deleted. Below are my code

{ command: { name: "destroy", text: "" }, title: "&nbsp", width: "110px" }],

I have some functions like

edit: function() {},
save: function (data) {},
dataBound: function() {}

Please suggest

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 30 May 2013, 06:28 AM
Hello Guillermo,


To achieve this you could bind to the remove event of the Grid, which is fired when a row is deleted and check if the currently deleted row is the last one.
E.g.
function remove(e) {
    var deleted = this.dataItem(e.row);
    var length = this.dataSource.view().length;
 
    if (this.dataSource.view()[length - 1] == deleted) {
        //custom actions
    }
}

I hope that this approach will work in the current scenario.

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Guillermo
Top achievements
Rank 1
answered on 05 Jun 2013, 10:39 PM
Thanks a lot it works for me.
Tags
Grid
Asked by
Guillermo
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Guillermo
Top achievements
Rank 1
Share this question
or