Domanda

Sto cercando di formattare un campo in una definizione BDC (Business Data Catalog), in SharePoint, con un separatore di migliaia.

Non sembra essere possibile nella definizione XML BDC e solo tramite SharePoint Designer (!). I campi che ho attualmente sono System.Decimal, quindi viene visualizzato come 12345.98, ma voglio che venga visualizzato come 12.345,98.

Sai se può essere raggiunto attraverso la definizione XML BDC?

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

Saluti

Nick

È stato utile?

Soluzione

XML è un meta-linguaggio non destinato a formattare o presentare informazioni, descrive e memorizza altri vocabolari. Ciò in mente, la risposta è: No, non puoi ottenere ciò che hai chiesto usando solo XML.

Un modo consigliato sarebbe usare l'XSLT < xsl: decimal -format / > nella webpart BDC List View o BDC Item View che stai utilizzando. Se si utilizzano i dati in altri modi, è possibile formattare facilmente l'output durante il rendering.

Supponi di avere questa porzione di codice che mostra il tuo tipo decimale:

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

Devi incapsularlo con qualcosa del genere (basato sull'esempio nel link):

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

Puoi trovare XSLT per la webpart nel menu Modifica web part condivisa o, come hai detto, usando SharePoint Designer.

Altri suggerimenti

Sembra possibile definire Complex Formatting in TypeDescriptor . Poiché non ho un ambiente per testare correttamente questa soluzione, le seguenti definizioni sembrano essere valide e affrontano il tuo particolare 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>

Nota come avvertito nella documentazione MSDN, "ComplexFormatting is slow". Forse è meglio attenersi alla Risposta F.Aquino

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top