2009-11-26 89 views
2

我试图在BDC(业务数据目录)定义中使用千位分隔符在SharePoint中格式化字段。格式化BDC字段

它似乎不可能在BDC XML定义中,并且只能通过SharePoint Designer(!)进行。我目前使用的字段是System.Decimal,因此它显示为12345.98,但我希望它显示为12,345.98。

你知道是否可以通过BDC XML定义来实现吗?

<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> 

干杯

尼克

回答

4

XML是一种元语言并非意在格式化或目前的信息,它描述和商店等词汇。记住这一点,答案是:不,您无法实现您仅使用XML所要求的内容。

推荐的方法是在您正在使用的BDC列表视图或BDC项目视图web部件中使用XSLT <xsl:decimal-format />元素。如果您通过其他方式使用数据,则可以在渲染过程中轻松地格式化输出。

说你有显示您的十进制类型的代码这一部分:

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

你需要的东西,如(基于链接的样品)来封装它:

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

你可以在修改共享Web部件菜单中找到Web部件的XSLT,或者如您所述使用SharePoint Designer。

2

Seems possible定义Complex FormattingTypeDescriptor元素。由于我没有的环境中正确测试这个解决方案,下面的定义似乎是有效的,并满足您的特定方案:

<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> 

注意的警告MSDN文档,"ComplexFormatting is slow"英寸也许最好坚持与F.Aquino answer