English 中文(简体)
Formatting of BDC Fields
原标题:

I m trying to format a field in a BDC (Business Data Catalog) definition, in SharePoint, with a thousand separator.

It doesn t appear to be possible in the BDC XML definition, and only possible through the SharePoint Designer(!). The fields I ve got at present are System.Decimal, so it displays as 12345.98, but I m wanting it to display as 12,345.98.

Do you know if it can be achieved through the BDC XML Definition ?

    <Parameter Direction="Return" Name="@ContactTotals">
      <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="Reader">
        <TypeDescriptors>
          <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Record">
            <TypeDescriptors>
              <TypeDescriptor TypeName="System.Int32" IdentifierName="dim_claims_key" Name="dim_claims_key" />
              <TypeDescriptor TypeName="System.Decimal" Name="total_outstanding" DefaultDisplayName="Total Outstanding (USD)" />
              <TypeDescriptor TypeName="System.Decimal" Name="total_paid" DefaultDisplayName="Total Paid (USD)" />
              <TypeDescriptor TypeName="System.Decimal" Name="total_incurred" DefaultDisplayName="Total Incurred (USD)" />
            </TypeDescriptors>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
  </Parameters>

Cheers

Nick

最佳回答

XML is a meta-language not intended to format or present information, it describes and stores other vocabularies. That in mind, the answer is: No, you cannot achieve what you asked using XML only.

A recommended way would be to use the XSLT <xsl:decimal-format /> element in the BDC List View or BDC Item View webpart you are using. If you are consuming the data trough other ways you can easily format the output during rendering.

Say you have this portion of code displaying your decimal type:

<xsl:value-of select="$ColName_0" />

You need to encapsulate it with something like (based on the sample in the link):

<xsl:value-of select="format-number($ColName_0,  #.###,00 ,  euro )"/>

You can find the XSLT for the webpart in the Modify Shared WebPart menu, or, as you said, using SharePoint Designer.

问题回答

Seems possible to define Complex Formatting at TypeDescriptor elements. As I don t have an environment to properly test this solution, following definitions seems to be valid and addresses your particular scenario:

    <Parameter Direction="Return" Name="@ContactTotals">
      <TypeDescriptor TypeName="System.Data.IDataReader, ..."
                      IsCollection="true" Name="Reader">

        <!-- note this -->
        <Properties>
            <Property Name="ComplexFormatting"
                      Type="System.String" />
        </Properties>

        <TypeDescriptors>
          <TypeDescriptor TypeName="System.Data.IDataRecord, ..." Name="Record">
            <TypeDescriptors>
              <TypeDescriptor TypeName="System.Int32"
                              IdentifierName="dim_claims_key"
                              Name="dim_claims_key" />
              <TypeDescriptor TypeName="System.Decimal"
                              Name="total_outstanding"
                              DefaultDisplayName="Total Outstanding (USD)" />

                  <!-- note this -->
                  <Properties>
                      <Property Name="FormatString"
                                Type="System.String">{0:#.###,00}</Property>
                  </Properties>
              </TypeDescriptor>
              ...
            </TypeDescriptors>
          </TypeDescriptor>
        </TypeDescriptors>
      </TypeDescriptor>
    </Parameter>
  </Parameters>

Note as warned in MSDN documentation, "ComplexFormatting is slow". Maybe is better to stick with F.Aquino answer





相关问题
SharePoint - Approaching Website Storage Limit Email

How can i go about changing the distribution list as well as the email text for the email that goes out to site collection admin when a site collection approaches it s size limit? Thanks for your ...

UI automated testing within SharePoint

I m looking for automated Functional Testing tools that can manipulate SharePoint sites, libraries, and documents thought the web interface. It needs to be extensible enough to handle any custom ...

Enable authorization on sitemap provider

I want to enable Authorization on the Site map provider. We have enabled anonymous access to the site and we want the Site map provider to be visible only to authorized users. I tried ...

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签