Showing Editing Links on a Multiple Item View in a DVWP
Laura Rogers over at EndUserSharePoint.com has a new series on the Data View Web Part (DVWP). All of her posts are great, but the Data View Web Part, The Basics – Multiple Edit Forms one showed me something I didn’t know that I could do with SharePoint Designer just by making some dialog box choices: add editing links.
First, check out her post above to find out how to display a multiple item form. The part that really caught my eye, though, was the second section about the Editing tab. Somehow I’ve never noticed that tab was even there. I’ve accomplished what it lets you do by writing my own XSL, and it isn’t horribly hard, but if Designer will let you do this without any work, why not?
First, add a plain old multiple item view DVWP to your page. Yes, that’s a view, not a form. Then, on the Common Data View Tasks, click Data View Properties, and go to the Editing tab. There you can decide if you’d like to:
- Show edit item links
- Show delete item links
- Show insert item link
Depending on which you select, you’ll see something like the screenshot below (thanks for the image, Laura). Each link lets you take actions on the items and save your changes right in the existing form (albeit with a browser refresh). No need to visit EditForm.aspx.
From here, you may decide to style the links differently, use different words, or make the links images rather than just text, but you’ve got a nice, full featured multiple item edit form in just a few minutes, tops! BTW, this UI choice is much safer than the Datasheet view, as your users have to click save once they’ve made their changes or they can use the ever-handy cancel.
Marc, what does “edit” do exactly? I tried it on an issues list, and it just allowed me to modify the title, not other fields like status or priority for example.
Christophe:
This approach is an interesting one because it lets you edit just the columns in the current view of the list in the DVWP. This means that you could expose just the columns you want users to be able to change through the DVWP and they won’t even see the rest of the columns at all. It isn’t a replacement for EditForm.aspx, but rather a different use case.
Make sense?
M.
Well, this is where I see a problem in my example: even though the priority and status columns are in the current view, SharePoint doesn’t let me modify them when I click on edit.
I just added an Issue Tracking list to a site and then put a DVWP onto a page like I outline above, exposing these columns:
* Created
* Assigned To
* Title
* Priority
* Approval Status
When I click on the insert or edit links, I can change all of the columns except the Approval Status, which I think makes sense, since that’s typically changed by a workflow or in some other construct.
Am I missing something about what you’re doing?
M.
OK, it works for me now. The first time, I added the priority and status columns later, maybe that’s the reason.
Thanks Marc!
Great, Christophe! I think that trick is pretty useful. Think about exposing a users own information from a list and letting them edit it right in a “real” page, as opposed to having to go to EditForm.aspx. Sort of nice!
Hey Marc,
I’m dyign to use this feature but the thign I can’t figure out is that I what to show say 3 fields but when you click the edit button I only want one of those fields to be editable. But even if I change the field type to label it is still editable. I want the users to see the person’s name but not be able to edit it – only edit another field. I can’t figure this out do you think its possible?
jm
John:
What you want to do is definitely possible. You’re probably just not changing the right bit of XSL. I’m not sure what you mean exactly by “change the field type to label”, but basically what you’ll want to do is to convert the form fields for the columns you want to “lock” into simple displays using instead. The other approach is to do what Christophe did accidentally above, and add the columns you *don’t* want to be editable afterwards.
If this isn’t enough to go on, feel free to contact me on the Contact link above so that you can send me your code to look at.
M.
Hi Marc,
Can i use conditional formatting for Delete link.
I wanted to show Delete link only if “Current login user is equal to Created By “.
I tried this but no luck…might be a different way i have to implement …
Please help me on this
Thanks in advance
Jam:
You certainly can do what you want. You’ll need to wrap the edit link in a xsl:if test where you check the current user against the Created By value. I doubt that you will be able to accomplish this without diving into the XSL directly.
M.
Marc ,
I did exactly what u said..applied conditional formatting on the link which i had to wrap with the above condition…the link got dissappeared but not visible as per the condition :(
I have done many conditional formatting but, this is the first condition behaving like anything
Well, it’s hard to say without seeing your code.
M.
Is there a way we can insert data into datasheet view through DVWP without having to create a custom web part.
Datasheet view and a DVWP are two entirely separate things. Datasheet view is a wonky ActiveX control which is virtually impossible to control; the DVWP can do pretty much anything you need.
M.
I need to build a datasheet kind of interface for multiple edits,inserts..Ive extensively used DVWP but dint find inline editing very useful for such task..I tried using JQGrid with SPservices and it displayed well,but its pretty tough to get it editing and insert new records in the JSON format..Is there a way I can build such an interface using HTML tables and spservices and use it for multiple edits,inserts,updates..I am using sp designer 2007//
I’ve done this is the past on some client projects with a DVWP. You can show multiple items in edit mode or create different templates.
However, I find it even better to use the DVWP to “paint” the page initially and then layer on jQuery and SPServices to add the behaviors and data saving you need. No postbacks!
M.
My client wants a datasheet view…I can do that with LVWP but the column names aint editable..any suggestions?
Can you explain how you’d like the column names to be editable?
M.
e.g. If in the list,its “abc”,it should be available to users as a more meaningful name like “Hostname”
Well, you can definitely change the column labels if you use a DVWP. It usually means some manual changes to the XSL, but not difficult ones.
M.