0

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?

2 Answers 2

1

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

1
  • While I didn't use this, I appreciate the help. Jul 13, 2010 at 18:12
1

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.

2
  • The <div still showing w/in the Summary column. How could I remove it? Sam
    – user3826
    Jun 21, 2011 at 18:48
  • @sam, You have to exactly follow the first few steps. Then double check your JavaScript. Jun 21, 2011 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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