Sign In
SharePoint Apps: Alexander Malek's weblog
using data views and workflow to build apps in sharePoint designer
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
SharePoint App-Building Tips
VSeWSS
Archive
Archives
November 2006
(1)
July 2006
(1)
June 2006
(4)
May 2006
(2)
April 2006
(2)
March 2006
(3)
February 2006
(2)
January 2006
(1)
December 2005
(2)
November 2005
(2)
October 2005
(3)
September 2005
(7)
Conditional Formatting Internals
MSDN Blogs
>
SharePoint Apps: Alexander Malek's weblog
>
Conditional Formatting Internals
Conditional Formatting Internals
Alex Malek
23 Feb 2006 3:15 AM
Comments
0
The inner workings of Conditional Formatting are actually pretty straightforward. The key construct that makes the feature possible is a tag called
<xsl:if>
, which is used to conditionally add content to the HTML output of the transform.
It's easiest to grok
xsl:if
with the "show content" type of CondF. Basically, the content you want conditional shown is wrapped in a
xsl:if
tag, where the
test
attribute of the tag defines the "condition" to be evaluated. If the condition is true, the content contained within the
xsl:if
gets output into the resulting HTML. If not true, nothing gets output.
<td>
<
xsl:if test="
@Units >= '500'
">
<
img src="Dc39.jpg" width="33" height="29" />
</xsl:if>
</td>
For "apply formatting" CondF, the markup is only slightly more complicated. In this case, the
xsl:if
part remains the same - the only trickiness is that in tis case we want to affect an attribute (style on the parent
<td>
container), not another tag. One does this by wrapping the
xsl:if
tag
with an
xsl:attribute
tag. Using the name attribute on the
xsl:attribute
tag, we can define which attribute the optional content gets added to. In this case, it's the "style" attribute.
<td>
<xsl:attribute name="style">
<xsl:if test="@Units >= '500'">
background-color: #FFFF00;
</xsl:if>
</xsl:attribute>
</td>
That's pretty much all there is to Conditional Formatting. One of the nice things about understanding the markup is that you can exact "formatting" you desire. Next time, I'll show you how how you can do some more advanced conditional formatting by manually editing the XSLT.
0 Comments
SharePoint App-Building Tips
Blog - Comment List MSDN TechNet
Comments
Loading...