Monday, November 05, 2012

SharePoint - Displaying list items with line breaks

This is how you can display list items that have line breaks (based on SharePoint 2010)

1- With SharePoint Designer, open the site and the list.
2- Under the 'Forms' section, open 'DispForm.aspx'.
3- Find the section below and add the fragments in bold:

<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" id="onetidPageTitleAreaFrameScript">
if (document.getElementById("onetidPageTitleAreaFrame") != null)

// Custom below:
$(document).ready(function() {    
     //var content = $(".ms-rtestate-field").find('div').html();
     $('DIV.ms-rtestate-field').each(function(index) {
        var innerdiv= $(this).find('div');
        if(innerdiv) {


4- Save

Note: to check if the list items are really storing the newline characters, you may use a CAML Query Builder.

No comments: