DCSIMG
Delete Item from Data View - Cizi

Cizi

From the desktop of SharePoint girl

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).

DataProperties

You can see that the links are added to the data view:

DataView2

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.

AreYouSure1

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

Comments

Cizi said:

Hi all, It has been a while since I have written my last post. Right now, I&#39;m in between exams but

# February 21, 2009 2:38 PM

Cizi said:

This is the last post in the series about changing the links ( delete , insert and edit). Finally, I&#39;m

# March 2, 2009 8:26 PM

wow gold said:

Wonderful article. I been looking for one on a similar note. I guess you always have something up your sleeve.

# April 24, 2009 8:20 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: