zoukankan      html  css  js  c++  java
  • SharePoint 计算列返回图片

    Hi

    i  created a calculated column (Status) and want to display image against the value of a particular field(Impact) in the list.
    it does not show me the image in the list, just shows the path of the image.
    result is below;

    Impact                                       Status
    1                                               /_layouts/images/kpidefault-0.gif
    2                                               /_layouts/images/kpidefault-1.gif
    3                                               /_layouts/images/kpidefault-2.gif

    formula for the calculated column is



    =IF(Impact="1","/_layouts/images/kpidefault-0.gif",
    IF(Impact="2","/_layouts/images/kpidefault-1.gif",
    IF(Impact="3","/_layouts/images/kpidefault-2.gif","Others")))



    any idea how to fix this?

    regards



    You have to  modify the 'Status' formula like below

    ="<DIV><IMG src='/_layouts/images/KPIDefault-"&IF(Impact="1","0.GIF",IF(Impact="2","1.GIF",IF(Impact="3","2.GIF","Chartreuse")))&"'></DIV>"

    Then after add content editor webpart exactly after the list webpart, then add the below code snippet in the source editor of content editor webpart

    • <script type="text/javascript">  
      //  
      // Text to HTML  
      // Feedback and questions: Christophe@PathToSharePoint.com  
      //  
      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) && (TDContent.indexOf("</DIV>") >= 0)) {  
      theTDs[i].innerHTML = TDContent;  
      }  
      }  
      catch(err){}  
      i=i+1;  
      }  
      //  
      // ExpGroupRenderData overwrites the default SharePoint function  
      // This part is needed for collapsed groupings  
      //  
      function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {  
      var tbody=document.getElementById("tbod"+groupName+"_");  
      var wrapDiv=document.createElement("DIV");  
      wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";  
      var theTBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var TDContent = " ";  
      while (j < theTBODYTDs.length) {  
      try {  
      TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;  
      if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {  
      theTBODYTDs[j].innerHTML = TDContent;  
      }  
      }  
      catch(err){}  
      j=j+1;  
      }  
      tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);  
      }  
      </script>  


  • 相关阅读:
    【OpenXml】Pptx的边框虚线转为WPF的边框虚线
    C#系列文章索引
    了解LINQ
    【爬虫系列】2. 打开App逆向“潘多拉魔盒”
    Makefile基础
    设计原则 开闭原则
    设计模式 工厂方法模式
    设计原则 接口隔离原则
    设计原则 迪米特法则
    设计原则 单一职责原则
  • 原文地址:https://www.cnblogs.com/ahghy/p/3124375.html
Copyright © 2011-2022 走看看