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: [email protected]  
    
    //  
    
    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>  


你可能感兴趣的:(SharePoint)