marți, iunie 13, 2006

Ophogus Quote Nuggets

"Everything is so important that it has to be done now now now, but not important enough to spend money to pay for resources to accomplish the least important of the most important tasks."

-Ophogus

Distinct Items from SharePoint List

I have recently had a need to display a list of distinct items. Perhaps you have the same need, and so I will share with you how to do it.

  • Open your view in FrontPage.
  • From the Data menu, select Insert Web Part.
  • Right-Click the web-part and select Convert to XSLT Data View.
  • If the Manage View Settings is not displayed, right-click your webpart and select Data View Properties.
  • Click Sort & Group.
  • Remove all fields from the sort order column, and add the field you want to display the distinct list of. I have an issues list, and I want 'Status'.
  • Select Show Group Header and Hide Group Details, then click OK.
  • Now, you have a (very ugly) distinct item list.
Edit it and make it beautiful.

You can mix and match items to make very powerful solutions. Mix this Distinct Item technique with the Conditional Formatting Woes Solved technique and the QueryString Parameter technique, you will do something that very few people have done in SharePoint (that I know of anyway):

  1. Display the distinct items list on your page.
  2. On the same page, place a web part that has a view which is filtered using a QueryString parameter.
  3. Use Conditional Formatting, and instead of formatting list values as images, format them as URLs to pass to the view.
Using my Issues list, I now have an issues list, with a list of distinct statuses, formatted as links to filter the view by each status.

If I get enought comments on this idea, I will post step by step, because formatting the distinct values as an href is kinda tricky.

Conditional Formatting FrontPage Memory Woes Solved

My previous post was complaining that memory was taxed to the max when the page you are editing in FrontPage has lots of conditional formatting. And by 'lots' I mean, about 40 or so (doesn't sound like much, does it?).

Anyway, I have abandoned the use of conditional formatting when I have to display an image, as exampled in my previous post. (Can't find it? Search for 'Nuclear' on my blog to get to it.)

This is how to avoid it:

For each status, have an image. One image for each status, each image the same size (otherwise the layout of your page might jump around a bit, I dunno, maybe that is what you want).

For me, I am using the issues list, and if we go by defaults (who does THAT anyway?), we see that there are 'Active', 'Resolved', and 'Closed' statuses for issues, and I have one image for each status:

  • CFActivebig.gif
  • CFResolvedbig.gif
  • CFClosedbig.gif
Note that the status name MUST appear in the image name, and the image names must conform to some standard naming convention that you can just make up. For me, I am using CF[status]big.gif as my naming convention because CF means that this is a conditional formatting image, and big means that it is the big image. (I plan on creating another view with tiny images representing each status as well, so I put the size into the naming convention.) My active image is a 100px wide by 20px high red image, Resolved is yellow, and closed is green. The images are just colored 100px by 20px rectangles.
  1. Open your view in FrontPage.
  2. Convert the view to XSLT Data View.
  3. Place the 'status' field where you want to display the image.
  4. Right-click one of the status names and choose 'Format Item As...', then choose 'Picture'.
  5. You will get a broken image, that's ok.
  6. Type 'ddd' next to the image (so that you can find the code that renders it).
  7. Go into code view.
  8. Type [ctrl]+F and search for 'ddd'.
  9. Change src="{@Status}" to src="CF{@Status}big.gif".
  10. Delete 'ddd' appearing just after the img tag.
  11. Upload your images to the list directory (or put them into the images directory, and map like this - Change src="{@Status}" to src="../../images/CF{@Status}big.gif".
You can now use this new-found knowledge to create your own, very complex conditional formatting projects without crashing your computer. And, on top of that, it is much easier to maintain. Think about things like what would happen if later in your project you wanted to put pictures of people who are users of the site, or picture of the person that the issue was assigned to, or all of the above in the same view.

Despre mine

Timi-Ostravia, Republic of Czedvia, Bulgaria
I make web applications. The tools I use are many and far between. I have been maining to learn Ruby and Python, and Perl. These tools are all like Lego to me. They can all be make to build things and have their strengths and weakest.