From the efforts of the bear http://www.cnblogs.com/Bear-Study-Hard/archive/2012/06/12/2545961.html
For more information about how to use "today" in a calculated column, see "Week" of bear (the column name in the calculation column uses today instead of the [] box), and then delete the today column.
I used the company's network to view the application of this computing column on a blog outside of China. I need to flip the wall to see it in China. I really don't know what can be blocked ...... Share it with you :)
A secondary column is required to achieve this KPI effect. Let me briefly describe the scenario. For a Sharepoint task list, we need to display different KPIs based on the relationship between today and due date.
The rule is as follows:
1 today <due date = green status icon
2 today> = due date = red status icon
3 due date not filled out = N/
1 create today column. column type is "Date and Time ".
2 create the first calculated column and named "datediff ".
3 input formula: = If ([due date] = ""; "2"; if (today <[due date]; "1"; "0 ")).
"0": Today> = due date
"1": Today <Due Date
"2": Due Date = ""
4 select "single line of text" of "the data type returned from this formula is ".
5 upload icons to the picture library which we want to use.
Here, modify it slightly:
1. Put the three files directly in the layouts directory, so that multiple sites can use the three images.
2. src = http: // nnitsharepoint/siteimage/ewr209m.gif to src = ../_ layouts/images/ewr219m.gif
The final calculated column value:
= If (status = "cancel", "<div> </div>", if (status = "issue ", "<div> </div>", if(Status = "completed", "<div> </div> ","")))
6 back to the list. create "status icon" column. column type is "calculated ". "The data type returned from this formula" is "single line of text ". input the formula:
= If ([datediff] = "1", "<div> </div> ", if ([datediff] = "0", "<div> </div> ", if ([datediff] = "2", "N/")))
7 we will get this result of this list.
8 now we have to change HTML to a picture.
Add a Content Editor Web part to the page and add it below the tasks Web part. And input its content.
<script type="text/javascript">//// Text to HTML//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>
9 we will see the result like this.
10 Delete the today column. We get the correct result.
Original address: http://sharepointpratik.blogspot.dk/2011/06/add-image-to-custom-list-with_30.html (Wall flip required)
Another way: http://www.cnblogs.com/ceci/archive/2010/04/09/1708182.html