Here I have selected a task list in which I have added a calculated field named “Indicator” and these indicators are calculated from the priority field which is categorized (high, Medium & Low).
Here is the code snippet for calculated field.
="<DIV><IMG
src='/_layouts/images/kpipeppers-"&(3-RIGHT(LEFT(Priority,2),1))&".gif'
/></DIV>"
Now added the following script in content editor webpart
<script type="text/javascript">
var theTDs = document.getElementsByTagName("TD");
var i=0; var TDContent = " ";
{
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){}
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>
Special thanks: Christophe
Thanks for shharing this
ReplyDeleteThaanks for writing this
ReplyDelete