none
Truncate Multiline of text Javascript Sharepoint 2010

    คำถาม

  • Hello All,


    I am following the below article to truncate the text in multiline of text column(plain text not rich text)(SHAREPOINT 2010)

    http://techtrainingnotes.blogspot.com/2010/12/sharepoint-how-to-truncate-multiline.html

    But I am not getting the more link option.somebody help me

    Following is the code

    <script>	
    var SummaryName = "Reports " ;
    var ColumnWithDropDown = 0;  //first column is 0
    var ColumnWithLongText = 1;
    var CharactersToShow   = 50;
    var isEnhancedRichText = true;
    
    var tables = document.getElementsByTagName("TABLE");
    for (var i=0;i<tables.length;i++)
    {
      if ( tables[i].summary == SummaryName )
      {
        var rows = tables[i].getElementsByTagName("TR");
        for (var j=1;j<rows.length;j++)
        {
          if (rows[j].childNodes.length > 2)
          {
            if ( rows[j].childNodes[ColumnWithDropDown ] == "[object Text]") 
              continue; // fix for FireFox
    
            var href = rows[j].childNodes[ColumnWithDropDown ].getElementsByTagName("A")[0].href
            if (href.toLowerCase().indexOf("dispform.aspx") == -1 && href.toLowerCase().indexOf("listid=") == -1  )
            {
    
              var docID = rows[j].childNodes[ColumnWithDropDown].childNodes[0].id
    
              // if not "dispform.aspx" then must be a library or links list
              // if "listid=" then must be a task list in 2010
              var parts = href.split("/");
              parts[parts.length-1] = "forms/DispForm.aspx?ID=" + docID;
              href = parts.join("/");
            }
    
    
            var theNode;
            if (isEnhancedRichText)
            {
              theNode = rows[j].childNodes[ColumnWithLongText].childNodes[0].childNodes[0];
            }
            else
            {
              theNode = rows[j].childNodes[ColumnWithLongText].childNodes[0];
            }
            if (theNode.innerHTML.length>CharactersToShow)
            {
              if (document.all)  // IE
                theNode.innerHTML = theNode.innerText.substring(0,CharactersToShow) 
                + "... <a href='" + href + "'><i>More</i></a>"
              else // FireFox
                try {
                theNode.innerHTML = theNode.textContent.substring(0,CharactersToShow) 
                + "... <a href='" + href + "'><i>More</i></a>"
                } catch (e) {}
            }
          }
        }
        
        break; // no need to check the other tables
      }
    }
    
    </script>

    Like Cricket







    • ย้ายโดย Lhan HanModerator 22 มิถุนายน 2555 1:52 sp2010 (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    • เปลี่ยนแปลงประเภท spguy2012 22 มิถุนายน 2555 5:33
    • แก้ไขโดย spguy2012 22 มิถุนายน 2555 9:03
    21 มิถุนายน 2555 12:19

คำตอบ

  • Hi,

    Please make changes to the following code:

    var ColumnWithDropDown = 2;  //first column is 0
    var ColumnWithLongText = 3;
    var CharactersToShow   = 50;
    var isEnhancedRichText = false;

    Thanks,
    Jinchun Chen


    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT microsoft.com(Please replace AT with @)

    • ทำเครื่องหมายเป็นคำตอบโดย spguy2012 23 มิถุนายน 2555 16:49
    22 มิถุนายน 2555 11:05

ตอบทั้งหมด