Delete Item from Data View
A few days ago I had to give my users access to delete items directly from the data view. I have noticed that the designer's default delete option is missing the validation question "Are you sure you want to delete this item?". This post will explain how to add the delete item link with the prompted question.
In Addition I didn't like the "Insert Item" and "Edit Item" links and I changed them as well – but this is issue for another post.
Adding delete link
After you add a data view to your page choose Data View Properties from Common Data View Tasks menu. In the Data View Properties window, under Editing tab click Show delete item links (I also checked the other options and will talk about them in another post).
You can see that the links are added to the data view:
If you click on the Delete link – the item will be deleted without asking you if you are sure about it.
Changing the link
look for this line in your page:
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit'))}">delete</a>
and replace it with (or just add the green text):
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit'))}" onclick="return DeleteItemConfirmation();"> delete</a>
The function DeleteItemConfirmation is a function from core.js that ask the user if he's sure about deleting this item.
It is important to say that there is no permission validation in this way – every user can see the delete link. However , if the user will click on the link without suitable permissions he will get the "Access Denied" page.
In the next posts i'll talk about the edit and insert option.
I hope this post was useful.
Inbar