View Style modifications – Empty fields, valuta fields…


At first view, I received a very simple issue about the fact the valuta-values were aligned right in a custom view.
 
Normally you would say: no problem, just add an alignment attribute to the column and give it the value ‘left’. But it doesn’t worked.
Why is that?
For the end-user the value was: "13,4€" but the actually value internally was "<div align=right>13,4€</div>".
 
I even found that sometimes when a value was supposed to be empty, it was actually "" or "

". In such cases, performing specific actions based on ’empty’ fields is horror!

 
Solution:
Within your CAML code, the value of Field element is sometimes formatted. You need only the ‘raw’ data. You can get this data by using the Column element. The Column element returns the raw data value for a particular field, as opposed to the formatted version provided by the Field element
 
<Column
  AutoHyperLink = "TRUE" | "FALSE"
  AutoHyperLinkNoEncoding = "TRUE" | "FALSE"
  AutoNewLine = "TRUE" | "FALSE"
    Default = "Text"
  Format="DateTime"
    HTMLEncode = "TRUE" | "FALSE"
    Name = "Text"
    ShowField = "Text"
    StripWS = "TRUE" | "FALSE"
  SubColumnNumber = Integer
    URLEncode = "TRUE" | "FALSE"
    URLEncodeAsURL = "TRUE" | "FALSE">
</Column>
 
If you want to use only raw data for specific type (like number, currency…), just use this syntax:
 
<Switch>
 <Expr><Property Select="Type" /></Expr>
 <Case Value="TypeName"><Column /></Case>
 <Default><Field /></Default>
</Switch>
 
Advertisements
This entry was posted in Sharepoint. Bookmark the permalink.

One Response to View Style modifications – Empty fields, valuta fields…

  1. jan says:

    Hi Steven,Im having exactly the same problem, but I cant make heads or tales from this solution. Can you elaborate or send me an example? My email address is jan.vercauteren A_T NC3A.Nato.int Thank you!Jan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s