2009-11-26 67 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