1

听起来很简单,但我从多个字段集中获取表中输出的值,因此管理员用户可以自定义表中显示的列。

这是我的功能页面块...

        <apex:pageBlock title="{!$Label.Search_Results}">
        <apex:pageBlockTable value="{!SearchResults}" var="pictureGallerySearchResult" title="SearchResults">
            <apex:column headerValue="Image" styleClass="imageDataCell">
                <a target="_blank" href="/servlet/servlet.FileDownload?file={!pictureGallerySearchResult.ActualAttachment.Id}" >
                    <img class="searchResultImage" style="{!SearchResultsImageStyle}" src="/servlet/servlet.FileDownload?file={!pictureGallerySearchResult.ActualAttachment.Id}" alt="{!pictureGallerySearchResult.ActualAttachment.Name}"/>
                </a>
            </apex:column>
            <apex:column headerValue="Test" value="{!pictureGallerySearchResult.Project[pictureGallerySearchResultField]}"/>
            <apex:repeat value="{!$ObjectType.Project__c.FieldSets.Picture_Gallery_Search_Results}" var="pictureGallerySearchResultField">
                <apex:column headerValue="{!$ObjectType.Project__c.Fields[pictureGallerySearchResultField].label}" value="{!pictureGallerySearchResult.Project[pictureGallerySearchResultField]}"/>
            </apex:repeat>              
            <apex:repeat value="{!$ObjectType.Store__c.FieldSets.Picture_Gallery_Search_Results}" var="pictureGallerySearchResultField">
                <apex:column headerValue="{!$ObjectType.Store__c.Fields[pictureGallerySearchResultField].label}" value="{!pictureGallerySearchResult.Store[pictureGallerySearchResultField]}"/>
            </apex:repeat>
            <apex:repeat value="{!$ObjectType.Visit__c.FieldSets.Picture_Gallery_Search_Results}" var="pictureGallerySearchResultField">
                <apex:column headerValue="{!$ObjectType.Visit__c.Fields[pictureGallerySearchResultField].label}" value="{!pictureGallerySearchResult.Visit[pictureGallerySearchResultField]}"/>
            </apex:repeat>
            <apex:repeat value="{!$ObjectType.Photo_Attachment__c.FieldSets.Picture_Gallery_Search_Results}" var="pictureGallerySearchResultField">
                <apex:column headerValue="{!$ObjectType.Photo_Attachment__c.Fields[pictureGallerySearchResultField].label}" value="{!pictureGallerySearchResult.PhotoAttachment[pictureGallerySearchResultField]}"/>
            </apex:repeat>
        </apex:pageBlockTable>
    </apex:pageBlock>

您可以看到我在第一列中为图像创建了一个“硬编码”超链接,但是如果它是自定义对象的名称字段,我想动态地超链接一个字段。

例如,如果字段集...

$ObjectType.Project__c.FieldSets.Picture_Gallery_Search_Results

...包含一个名为“名称”的字段,我想插入一个超链接,将您带到销售人员页面以查看该项目。

因此,首先我需要能够确定该字段是否是自定义对象名称字段,其次,输出超链接而不是标签。

如果有人有任何想法,我将不胜感激。

感谢您抽时间阅读。

4

2 回答 2

2

您是否考虑过在 APEX 控制器/扩展中执行此逻辑?执行查询后,您可以遍历结果,确定您希望每个超链接的内容,并填充您向 Visualforce 页面公开的地图,该地图由搜索结果中的某个唯一值(可能是 ID)和值将是超链接。然后在您的 Visualforce 迭代器中,您可以执行 map[SearchResult.Id] 或任何最终的键。

于 2013-02-02T04:29:02.097 回答
1
<apex:column headerValue="{!$Label.Filename}">{!pictureGallerySearchResult.ActualAttachment.Name}</apex:column>
<apex:repeat value="{!$ObjectType.Project__c.FieldSets.Picture_Gallery_Search_Results}" var="pictureGallerySearchResultField">
    <apex:column headerValue="{!$ObjectType.Project__c.Fields[pictureGallerySearchResultField].label}">
        <apex:outputLabel value="{!pictureGallerySearchResult.Project[pictureGallerySearchResultField]}" rendered="{!NOT(ShowResultFieldHyperlinkMap[$ObjectType.Project__c.Fields[pictureGallerySearchResultField].label])}"/>
        <apex:outputLink value="{!URLFOR($Action.Project__c.View, pictureGallerySearchResult.Project['Id'])}" rendered="{!ShowResultFieldHyperlinkMap[$ObjectType.Project__c.Fields[pictureGallerySearchResultField].label]}" styleClass="resultFieldHyperlink">
            <apex:outputLabel value="{!pictureGallerySearchResult.Project[pictureGallerySearchResultField]}" styleClass="resultFieldHyperlinkLabel"/>
        </apex:outputLink>
    </apex:column>
</apex:repeat>
于 2013-02-19T09:52:36.100 回答