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

Delete a row from Kendo Grid

1 Answer 508 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 02 Sep 2014, 06:46 PM
I have a case where users do not want to use the buttons to create new rows in the grid. Instead they want to have the rows created when they tab out of some input controls. I was able to achieve this but ran into a problems with Shift+Tab or clicking outside the grid with out tabbing out. Below is the approach:

1. I have a text box just above the grid. I am creating new row once the user leaves that text box.
2. I will create a second new row if they tab out of the last input control in the grid.
3. I will delete the existing row and stop creating a new row if they tab out of all the controls in a grid row with out entering anything. Row will be deleted once the user tabs out of the last control in the grid.

This is perfectly working if they follow this exactly. But at any point if they come out of the Grid by using mouse and then do a Shift+Tab to go back into the Grid they are stuck in there and cannot get out of the grid. I have noticed this is happening because of the empty row that is already in the grid which is not deleted. To avoid this scenario I want to change the Point 3 above such that I will delete the row even if the user comes out of the grid from any control in the grid line.

However when I try to do this, using removeRow() is not deleting the row when I use it for the first control but it works if I uses it in blur of the second control (Considering only two column for the row)

Here is the DoJo for the case but this one has a problem as this is not even deleting the row at all where as I can delete the row from the second control in my application.

In simple words what I want to achieve is : I want to delete the rwo if user tabs out with our entering anything in the input control.

I cannot use Cancel changes as I am saving the records along with other information on the form. Cancel changed delete all unsaved records from grid which is not suitable for my case.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 04 Sep 2014, 10:47 AM
Hi Raja,

Based on the provided information, my understanding is that the custom implementation and algorithms do not correspond to the business requirements, however, this is not an ussue caused by the Grid.

You can subscribe to the focusin and focusout events of the Grid <div>. When these events are fired, you will know that the user has clicked on something inside or outside the Grid, or has tabbed inside or outside the Grid. Then execute whatever you need the widget to do. The relevant Grid and DataSource APIs that you may additionally need, are:

http://docs.telerik.com/kendo-ui/api/web/grid

http://docs.telerik.com/kendo-ui/api/web/grid#fields-dataSource

http://docs.telerik.com/kendo-ui/api/framework/datasource

Regards,
Dimo
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
Raja
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or