Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a Tasks List, and the text ends up in the Description field.
The problem is that when I display the task, the Description field displays all the text.
I'd like to just have 40 or 60 characters or so display.

I've tried to create another field with a calculation value of =LEFT(Description,45), but you can't access Multi-Line fields in a calculated column.

Any ways to do this without programming?

If I need to code it, what do I need to do?

share|improve this question
add comment

2 Answers

Use an XLST data view (you can turn a regular view into XSLT using SPD) and then truncate your value using XSL

share|improve this answer
    
While I didn't use this, I appreciate the help. –  Lance Roberts Jul 13 '10 at 18:12
add comment
up vote 1 down vote accepted

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 <div> 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.

share|improve this answer
    
The <div still showing w/in the Summary column. How could I remove it? Sam –  user3826 Jun 21 '11 at 18:48
    
@sam, You have to exactly follow the first few steps. Then double check your JavaScript. –  Lance Roberts Jun 21 '11 at 20:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.