You need to sign in to do that
Don't have an account?
Display less in a cell of a Data Table
Hi,
I have a pageBlockTable that outputs a list of custom items that I created in APEX. One of the columns extract a very long string which I only want to show part of the string the Table instead of the entire string block which makes the table big and huge.
I'd like to maybe display the first 3-5 lines on this block and if the user wishes to see more than they will need to click on the row to open a new window to the record.
Here is the VF Table code:
<apex:outputPanel layout="block" style="overflow:auto;height:500px" > <apex:pageBlock id="timeline" title="Timeline" > <apex:pageBlockTable value="{!Emessages}" var="e" rendered="{!NOT(ISNULL(Emessages))}"> <apex:column value="{!e.eventID}"> <apex:facet name="header">ID</apex:facet> </apex:column> <apex:column value="{!e.eventType }"> <apex:facet name="header">Type</apex:facet> </apex:column> <apex:column value="{!e.eventMainBody}" > <apex:facet name="header">Main Body</apex:facet> </apex:column> <apex:column value="{!e.eventFromOrCreatedBy}"> <apex:facet name="header">Created By or From</apex:facet> </apex:column> <apex:column value="{!e.eventCreatedDate}"> <apex:facet name="header">Created Date</apex:facet> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel>
The line
<apex:column value="{!e.eventMainBody}" >
is the line that dumps the entire block of string which typically is a dump of the TextBody of an EmailMessage record (very long text at times!)
Here is what it looks like: example of VF table
How do I resize the column to only display a few lines instead of everything?
Many thanks all.
Regards,
Joey Ho.
Try changing above to
Hello Joey,
Please try this:
<style>
.wrapping {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
and then in your table:
<td class="wrapping">your text here</td>
Hope this helps!
Thanks Avi and Vinita,
Although both your solutions did not get my requirements, using both your methods allowed me to get a solution together which got what I needed! (Please note I have very little skill in HTML/CSS coding so what I did here was trialling different codes!)
Here's what I did:
Used Vinita's suggestion to include styles but instead of using pre-wrap for white-space I used pre-line instead. This provided a better view for me.
The main collumn changed to include <div> tag that Avi recommended but used overflow:hidden along with class=wrapping to include the styles
Thanks all.