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

Deleting row in grid

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
P
Top achievements
Rank 1
P asked on 22 Feb 2010, 03:28 PM
Hi,
I have 2 problems with deleting row in grid (ajax databinding mode)
1.  Need to have confirmation, that user is sure that he want to delete row. Confirmation box is comming up when user clicks delete button. But it doesn't mather what user presses in confirmation (ok, or cancel), the row is being deleted any ways.

columns.Command(p => p.Delete()).Width(100).Width(100).HtmlAttributes(new { onclick = "return confirm('Are you sure?')" });

2. After user click delete button (with confirmation box or without) row is deleted from database, but grid is not refreshed.
Row disapears after manual refresh.

Thank you for help in advance

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 22 Feb 2010, 05:25 PM
Hello P,

Currently to add confirmation dialog you need to modify telerik.grid.editing.js. Find this code:
$('.t-grid-delete', grid.element).live('click', function(e) {
                e.preventDefault();
                grid.deleteRow($(this).closest('tr'));
            });

And replace it with this
$('.t-grid-delete', grid.element).live('click', function(e) {
                e.preventDefault();
                if (confirm('Are you sure?'))
                grid.deleteRow($(this).closest('tr'));
            });

For the second problem - make sure you the action method returns data for the binding as demonstrated in the ajax editing example. Also remove your previous code (setting the onclick html attribute).

Greetings,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
P
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or