BCSモデルからspfieldurlvalueプロパティを表示します
-
16-10-2019 - |
質問
私は非常にシンプルなBCSモデルを持っています:
public Guid Id { get; set; }
public SPFieldUrlValue Url { get; set; }
public string Description { get; set; }
public string Owner { get; set; }
public DateTime CreatedOn { get; set; }
URLプロパティには、SharePoint HyperLinkプロパティと同様に、タイトルとURLの両方が含まれています。 BCSモデルには、ReadListメソッドとReadItemメソッドの両方に次のタイプ記述子があります。
<TypeDescriptor Name="Url" TypeName="Microsoft.SharePoint.SPFieldUrlValue">
<Properties>
<Property Name="SPCustomFieldType" Type="System.String">`URL</Property>
</Properties>
</TypeDescriptor>
リスト定義のschema.xmlでは、フィールドコレクションに次の値があります。
<Field Name="BdcIdentity" DisplayName="BDC Identity" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="BdcIdentity" Type="Text" />
<Field Name="Id" DisplayName="Id" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Id" Type="Text" />
<Field Name="Url" DisplayName="Url" Format="Hyperlink" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Url" Type="URL" />
<Field Name="Description" DisplayName="Description" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Description" Type="Text" />
<Field Name="Owner" DisplayName="Owner" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Owner" Type="Text" />
<Field Name="CreatedOn" DisplayName="Created On" Hidden="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="CreatedOn" Type="DateTime" />
あまりにも派手なことはありません。ただし、デフォルトビューを開くと、テーブルビューにURLが適切に表示されません。何も表示されません。個々のアイテムビューでは、適切に表示されます。 UIで適切にレンダリングするためにSpfielidurlValueを取得する方法についての考えはありますか?
解決
2か月半後(!!!!)PSSは、レイアウト/XSLに保存されるカスタムXMLスタイルシートを使用して回避策を考え出すことができました。
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:template match="FieldRef[@Name='Url' and @Format='Hyperlink']" mode="URL_body" priority="1">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="url" select="normalize-space(substring-before($thisNode/@*[name()=current()/@Name],','))" />
<xsl:variable name="desc" select="normalize-space(substring-after($thisNode/@*[name()=current()/@Name],','))" />
<xsl:variable name="descfld" select="$thisNode/@Description"/>
<xsl:variable name="urlfld" select="$thisNode/@Url"/>
<!-- URL: <xsl:value-of select="$urlfld" /><br/>
Description: <xsl:value-of select="$descfld" /><br/>
Link: -->
<a href="{$url}" alt="{$desc}">
<xsl:value-of select="$desc"/>
</a>
</xsl:template>
</xsl:stylesheet>
他のヒント
MSDNページによると BDCカスタムプロパティ:
このプロパティは、特定のファインダー以外の方法には影響しません。
どうすればこのXSLを実装できますか?オフコースはそれを作成し、レイアウト/XSLに展開できます...しかし、外部リストとXSLファイルの間に接続はありませんか?
所属していません sharepoint.stackexchange