1,804 articles and 14,767 comments as of Tuesday, April 19th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint (Joel Oleson) content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Tuesday, September 7, 2010

SharePoint: Extending the DVWP – Part 34: Using Icons for Form Action Links

Author: Jim Bob Howard

Last time, we started putting the final touches on the look-and-feel of our DVWP, taking care of 1-5 below. This time, we’ll finish up with adding the icons at 6 & 7.


Greg Schaefer had a great suggestion in the midst of this series, which caused me to change my form actions to links to images. Greg suggested I take a look at Peter Allen’s blog post about SharePoint Layout Images for built-in images I could use in place of text links for the form actions: update, remove, and insert.

This is a result of implementing Greg’s suggestion.

Iconifying the Links

Peter has put together a great resource for searching through the SharePoint Layout Images even if you have admin access to the /_layouts/images/ directory.

That’s where I found these icons above:


Update

edititem.gif

Remove

crit_16.gif

Insert

newitem.gif

To use them is dead simple:

  1. Click on the link
  2. Replace the text of the link with the image:
  3.     <a href="javascript: {ddwrt:GenFireServerEvent(concat('__cancel;dvt_1_form_editkey={',$KeyValue,'}'))}">update</a>
    

    …becomes:

        <a href="javascript: {ddwrt:GenFireServerEvent(concat('__cancel;dvt_1_form_editkey={',$KeyValue,'}'))}"><img src="/_layouts/images/edititem.gif" border="0" alt="" /></a>
    
  4. Rinse and repeat with the remove link. Here’s another possible image for remove:

  5. Remove

    Delitem.gif

    With the images, the vertical bar we added before isn’t needed… but a little margin definitely is:

    <td class="ms-vb" width="1%" nowrap="" style="padding-left=3px">
        <a href="javascript: {ddwrt:GenFireServerEvent(concat('__cancel;dvt_1_form_removekey={',$KeyValue,'}'))}"><img src="/_layouts/images/crit_16.gif" border="0" alt="" /></a>
    </td>
    
  6. For insert, I also added some more descriptive text:
  7.  <a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}"><img src="/_layouts/images/newitem.gif" border="0"/> Add a new employee</a>
      

And… That’s a Wrap

Well, it’s taken 34 parts to get here. Nothing left but putting all the parts together into one workable solution. We’ll do that next time when we FINISH Extending the DVWP.

Author: Jim Bob Howard

Jim Bob Howard is a web designer / webmaster in the healthcare industry. He has been working with SharePoint since March 2009 and enjoys sharing what he has learned. He is a moderator and frequent contributor to Stump the Panel, and answers SharePoint questions on Twitter (@jbhoward) and via email ([email protected]).

View all entries in this series: Extending the DVWP»
Entries in this series:
  1. SharePoint: Extending the DVWP - Part 1: Layout Enhancement - Rearranging Columns - Default and Edit Templates
  2. SharePoint: Extending the DVWP - Part 2: Layout Enhancement - Rearranging Columns - Insert Template
  3. SharePoint: Extending the DVWP – Part 3: Getting it All on One Line - DVWP Function Action Links
  4. SharePoint: Extending the DVWP – Part 4: Turning DVWP Action Links into Buttons
  5. SharePoint: Extending the DVWP – Part 5: Doing Stuff Before Save on Submit - PreSaveAction()
  6. SharePoint: Extending the DVWP – Part 6: Examining the Form Action Links
  7. SharePoint: Extending the DVWP – Part 7: Creating a Form Action Workflow
  8. SharePoint: Extending the DVWP – Part 8: Creating a Form Action Workflow - The After Math
  9. SharePoint: Extending the DVWP – Part 9: Oops! Failed Setting Processor Stylesheet
  10. SharePoint: Extending the DVWP – Part 10: Passing Workflow Variables to a Form Action Workflow
  11. SharePoint: Extending the DVWP – Part 11: Getting More Form Fields to the Workflow
  12. SharePoint: Extending the DVWP – Part 12: Adding More Form Fields from the Data
  13. SharePoint: Extending the DVWP – Part 13: Putting PreSaveAction() to Work – Creating Variables
  14. SharePoint: Extending the DVWP – Part 14: Putting PreSaveAction() to Work with jQuery
  15. SharePoint: Extending the DVWP – Part 15: User-Managed Dropdowns with Site Columns
  16. SharePoint: Extending the DVWP – Part 16: User-Managed Dropdowns - Loading Data
  17. SharePoint: Extending the DVWP – Part 17: User-Managed Dropdowns – Creating a Relationship list
  18. SharePoint: Extending the DVWP – Part 18: User-Managed Dropdowns – Loading the Relationship list – Part 1
  19. SharePoint: Extending the DVWP – Part 19: User-Managed Dropdowns – Loading the Relationship list – Part 2
  20. SharePoint: Extending the DVWP – Part 20: Cascading Dropdowns - Applying the jQuery
  21. SharePoint: Extending the DVWP – Part 21: Cascading Dropdowns - Three-tier Cascade
  22. SharePoint: Extending the DVWP – Part 22: Creating Title Based on Other Fields with jQuery
  23. SharePoint: Extending the DVWP – Part 23: Creating Title Based on Other Fields with a Workflow
  24. SharePoint: Extending the DVWP – Part 24: A Note to Readers
  25. SharePoint: Extending the DVWP – Part 25: Using an Audit Trail by Creating List Items with SPServices
  26. SharePoint: Extending the DVWP – Part 26: Modifying the Edit Template
  27. SharePoint: Extending the DVWP – Part 27: Adding an Alternate Edit Template to a DVWP
  28. SharePoint: Extending the DVWP – Part 28: Massage the Remove Template
  29. SharePoint: Extending the DVWP – Part 29: Modifying Form Action Workflows on the remove Template
  30. SharePoint: Extending the DVWP – Part 30: Using EasyTabs with Filtered DVWPs to Make Data Manageable
  31. SharePoint: Extending the DVWP – Part 31: Filling in Default Data on the insert Template with jQuery
  32. SharePoint: Extending the DVWP – Part 32: Filling in Default Data on the insert Template with Multiple DVWPs
  33. SharePoint: Extending the DVWP – Part 33: Modifying Total and Subtotal Row Layouts in DVWP
  34. SharePoint: Extending the DVWP – Part 34: Using Icons for Form Action Links
  35. SharePoint: Extending the DVWP – Part 35: Putting it All Together
  36. SharePoint: Extending the DVWP – Bonus: Fixing the Insert Form Action When "No Matching Items"
  37. SharePoint: Extending the DVWP – Bonus: Creating a Title Based on Dropdowns with jQuery
 

Please Join the Discussion

11 Responses to “SharePoint: Extending the DVWP – Part 34: Using Icons for Form Action Links”
  1. Kurup says:

    Hi Jim,

    I have a Data View Webpart which uses the normal filter options available.

    Now I have done the following customizations to achieve some results

    • To remove these duplicates in the data view webpart filter option , do the following:
    In SPD Find the code:

    Remove the [1], like this:

    This should remove the duplicate entries.
    • To have the filter view expanded by default and retained on every select

    Have filter added to dvt_adhocmode

    filter

    • For Setting the default sort and grouping options.

    Set the parameter values to the names of the columns in the data set for each corresponding parameter.
    Practice
    ClientName

    • To remove the filters that we do not want to show

    To find the correct location in the XSL where this should be done, search for the following text:

    Just below this xsl:if statement, a table is created that contains the filter drop downs. To remove a filter delete everything in between and including the and tags for that element. For example, In the above filter row I want to remove the ProjectName filter, I would find the section that corresponds to the column that I don’t want to show and where the filedname parameter matches ProjectName and I would delete the entire section shown below.

    ProjectName
    ProjectName

    text

    Once I have removed all of the filters that I don’t want to show.


    Now I have three filters . But the issue is my filters selections are not retained. When I make a filter selection , the previous selection is going back to “All”. Could you please help me fix this?

    • Dear Kurup,

      Good question. (And I did get your email, too.) ;)

      It’ll take some strong tweaking in the XSL to make it work the way you’re asking, because the DVWP defaults to one filter field rather than ANDing filters to each other.

      You’d probably want to rewrite the Filter toolbar to not do an immediate postback on click, so that you can choose more than one. And then you’d probably also need to include an option to let the user choose “OR” or “AND” so you’d know if the filters were supposed to include all entries with either filter selection, or only include entries that contained both.

      If you want to bring this over Stump the Panel (http://www.endusersharepoint.com/STP), we can get several good minds working on it.

      Blessings,
      Jim Bob

  2. Nathan Wells says:

    That DVWP looks seriously professional. Great job and thanks for writing this series, there’s some great content throughout – looking forward to the final part.

  3. George W says:

    BRAVO !!! !!
    This is a goldmine of easy to follow steps.!!!

  4. Greg says:

    Jim,

    This is an amazing effort you are now completing. The quality of your documentation is what will make it a true reference for all DVWP builders. I am sure an e-Book would sell like crazy (I would keep the readers comments in it thought).
    This was a long serie to follow but the quality and reusability factors are offsetting this by a landslide.

    Kudos to you.
    Greg

  5. Thanks, Greg and George. Glad to be of service.

  6. Rene says:

    Thanks Jim, I was looking for the site with the SharePoint icons (Paul Allen’s) for a few days, but couldn’t find it. Coincidentally, I just read this post here and rediscovered it.

    Now that your series is completed I’ll go through it again, it’s been a long time since I saw the beginnings of it…

Trackbacks

Check out what others are saying about this post...
  1. [...] Finally, to make it look even nicer, we’ll massage the way total and subtotal rows look and replace some of our form action links with icons. [...]




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!