简体   繁体   English

文本上的新 Visualforce 页面 onClick

[英]New Visualforce page onClick on a text

I am new to Apex.我是 Apex 的新手。 I am trying to create an object with 2 fields: Subject(Text) and Description(Rich Text Area).我正在尝试创建一个具有 2 个字段的 object:主题(文本)和描述(富文本区域)。 This should be displayed in a table format.这应该以表格格式显示。 The description should display only the first 50 characters, and onclick on the description, it should open a new Visualforce page to display the entire content.描述应该只显示前 50 个字符,并且描述上的 onclick 应该打开一个新的 Visualforce 页面来显示全部内容。

<apex:page controller="Notes_Controller" >
<apex:form >
  <apex:pageBlock >
    <apex:pageBlockTable value="{!recordsList}" var="n">
        <apex:column value="{!n.Subject__c }" headerValue="Subject"/>

        <apex:column styleClass="slds-truncate" headerValue="Description"> 
            <apex:facet name="header">Description</apex:facet>

            <apex:outputLink value="{!n.Description__c}" target="_blank">{!LEFT(n.Description__c,50)}
            </apex:outputLink>
           </apex:column>
    </apex:pageBlockTable>
 </apex:pageBlock>
</apex:form>

So far I have tried the above, but I am unable to get the entire description to open up in a new tab.到目前为止,我已经尝试了上述方法,但我无法在新选项卡中打开整个描述。 Any ideas?有任何想法吗?

Can this be done using a formula field?这可以使用公式字段来完成吗? I tried using outputlink where value = description and label is the subject, such that click on the subject name will take you to the description.我尝试使用 outputlink where value = description 和 label 是主题,这样点击主题名称将带你到描述。 But I get "Url does not exist".但我得到“网址不存在”。

Any help is appreciated.任何帮助表示赞赏。

In the apex:outputLink you can try the value attribute specify URLFOR with the action and Id.在 apex:outputLink 中,您可以尝试使用 value 属性指定 URLFOR 与操作和 Id。

Something like就像是

<apex:outputLink value="{!URLFOR($Action.n.Description__c)}" target="_blank">{!LEFT(n.Description__c,50)}
            </apex:outputLink>

The apex:outputlink value should be a url. apex:outputlink值应该是 url。 URLFOR(Description__c) will not work since Description is a text field. URLFOR(Description__c)将不起作用,因为 Description 是一个文本字段。

Try <apex:outputLink value="/{.n.id}" target="_blank">{,LEFT(n:Description__c,50)}</apex:outputLink>试试<apex:outputLink value="/{.n.id}" target="_blank">{,LEFT(n:Description__c,50)}</apex:outputLink>

See apex:outputLink顶点:输出链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM