How To: 用 SharePoint 计算列做出你自己的KPI列表

         关于这个计算列的应用我是利用公司的网络在国外的blog看到的,国内需要FQ才能看到,真不知道这有什么可封的,唉……分享给大家吧:)

         要做成这个KPI效果需要一个辅助的Column。我先简单叙述一下场景。一个SharePoint Task列表,我们要根据Today和Due Date两个时间之间的关系来显示不同的KPI。

 

         规则是这样的:

         1 Today < Due Date = Green Status Icon

         2 Today >= Due Date = Red Status Icon

         3 Due Date not filled out = N/A

 

         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.

         

         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><img src=http://nnitsharepoint/SiteImage/ewr209m.gif></DIV>",IF([DateDiff]="0","<DIV><img src=http://nnitsharepoint/SiteImage/ewr210m.gif></DIV>",IF([DateDiff]="2","N/A")))

         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.

         

 

         原文地址: http://sharepointpratik.blogspot.dk/2011/06/add-image-to-custom-list-with_30.html(需要FQ)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值