While designing a custom field type, you may sometime need to render different HTML based on the value of field. For example, if you want to display Red,Amber, Green traffic light images to highlight High,Medium, Low value then you need to dynamically switch image url based on the value of the field.
In CAML, you have Case structure to implement this switching logic. It works very much like the C# switch-case statement. Following is an example of RenderPattern of a custom field which display different images based on the value of the field.
<RenderPattern Name="DisplayPattern"> <Switch> <Expr> <Column /> </Expr> <Case Value="1" > <HTML><![CDATA[<img alt="Red" src="/_layouts/IMAGES/ewr210m.gif" />]]></HTML> </Case> <Case Value="2" > <HTML><![CDATA[<img alt="Amber" src="/_layouts/IMAGES/ewr211m.gif"]]></HTML> </Case> <Case Value="3" > <HTML><![CDATA[<img alt="Green" src="/_layouts/IMAGES/ewr209m.gif"]]></HTML> </Case> <Default> <HTML><![CDATA[<span>No Value</span>]]></HTML> </Default> </Switch> </RenderPattern>
Hi,
Thank you for putting this post. I was exactly looking for it. Great Job
Hi,
Thanks for the post.I need to use the “greater than” expression on this post.For example;
case value>7
case 7>value>3
case 3>value
I need these 3 cases.So How can I integrate these expressions to this code?