+ Start a Discussion
Dave BerenatoDave Berenato 

Apex Output Field that is Truncated with Show More Link

If I have a column in an Apex:PageBlockTable for a Long Text Area, can I have the field Truncated to a certain number of characters with a Show More Link?
 
<apex:column width="300px">

            <apex:facet name="header">Description</apex:facet>

            <apex:outputText value="{!task.description}"/>

        </apex:column>

Some kind of href that will display the full field if clicked?
Raj VakatiRaj Vakati
You need to use jquery or javascript to do this
refer this link 
https://stackoverflow.com/questions/5720192/how-to-truncate-links-to-certain-length-using-any-of-the-javascript-or-jquery
Dave BerenatoDave Berenato
Hi Raj,

I tried what was in the link:
 
<apex:page doctype="html" showheader="false">

<script>
jQuery("a").each(function(i, value) {
   var $link = jQuery(value);
   var text = $link.text();

   if(text.length > 25) {
      $link.text(text.substring(0, 21) + "...");
   }
});
</script>

<a href="http://www.google.com">This is some really long text that is over 25 characters long</a>

</apex:page>

But they have the href as Google. How can I make it so that it can have the first 100 or so characters be plain text and then have a "Show More" with an href to load to the remaining characters?