tags:

views:

970

answers:

2

The clearest way to explain this is with an image:

http://i42.tinypic.com/fc1gdk.png

I want to only show the first two lines of the "Solution" field, as otherwise with a long solution, it becomes very hard to browse the list. Is this possible? I've looked at the list and view options, and nothing is apparent.

+1  A: 

Cannot see image, corporate blockage, but for a text column this will work.

Create a new column and make it calculated, make the formula =left("your column",2000) then use the calculated column in your views.

Will Dieterich
Thanks, looks great. It would have worked, except formulas can be applied to a "single line of text" datatype, but not multiple lines.I get this message: One or more column references are not allowed, because the columns are defined as a data type that is not supported in formulas. For others who are interested, the actual formula should be:=LEFT([Solution],500) or however many characters you wish to limit.
me_here
You can use a SPD workflow to copy the multi-line to a single line then use the left function onthat column, but you will get HTML in the column; or make a code based workflow. Change multi-line to plain text if possible Other option is the change the display.aspx page so you have a custom List Form then modify text using xslt, but even then you have the change of removing the ending tags of the HTML.
Will Dieterich
A: 

Here's how to do it, and yes it's a little complicated:

First, create a single-line text column, I'll call it Content

Second, create a calculated column, I'll call it ContentCalc, set the formula to =[Content]

Third, delete the first column Content, then recreate it as a multi-line text column

Fourth, create a third column, I'll call it Summary, and set the formula to =LEFT([ContentCalc],60), with 60 being any number of chars you want to truncate it to

Finally, to get rid of the stuff, insert the following source into a Content Editor Web Part placed under the list:

<script type="text/javascript">
  var theTDs = document.getElementsByTagName("TD");
  var i=0;
  var TDContent = " ";
  while (i < theTDs.length)
  {
    try
    {
      TDContent = theTDs[i].innerText || theTDs[i].textContent;
      if (TDContent.indexOf("<div") == 0)
        {
          theTDs[i].innerHTML = TDContent;
        }
    }
  catch(err){}
  i=i+1;
  }
</script>

I got the bulk of this from this link, but I had to mod the instructions a little, and it still took a while to implement exactly right.

Then, if you want to keep the Calc columns from displaying in the Display form, you'll have to create a custom form.

NOTE: This javascript doesn't work for Extended Rich Text because it affects after the truncation, and the div tag is too long for the amount I was truncating. By extending the amount of chars in my truncation I was able to get it to work mostly. There are still some edge cases I haven't figured out completely yet.

Lance Roberts