ใน SharePoint List จะสร้างแถบสี หรือใส่ สัญลักษณ์ให้กับ Column ของข้อมูลที่สนใจได้อย่างไร (SharePoint 2007)

Posted: กันยายน 3, 2010 in Issue Tracking, SharePoint List, Task List
ป้ายกำกับ:, , , ,

          ใน SharePoint List ต่างๆ เช่น Issure Tracking หรือจะเป็น Task List โดยปกติ ก็จะแสดงข้อมูลในฟิลด์ต่างๆ โดยไม่ได้มีลูกเล่นหรือสีสันบ่งบอกความแตกต่างของแต่ละ Item  เราลองมาประยุกต์ใช้ Calculate Column เพื่อทำให้ SharePoint List ของเราสะดวกต่อการดูข้อมูล โดยใช้สีมาเป็นตัวบ่งบอกกันคะ  ดังรูปด้านล่างนี้คะ      
        

                จากตัวอย่าง อธิบายขั้นตอนโดยคร่าวๆ ก่อนนะคะ  Column ที่ถูกแสดงเป็นสัญลักษณ์ หรือข้อความที่ถูก Hightlight พวกนี้ (เช่น Column ที่ชื่อ Traffic Light,Indicator,Font Color และ Background Color) เป็น Calculate Column  โดย Column ที่ใช้ในการกำหนดเป็น Condition คือ Column Priority ที่ไว้บอกความสำคัญของ Issue นั้นๆ โดยที่ Calculate Column  ก็ให้ใส่ Code HTML ที่ต้องการแสดงผล ว่าจะให้แสดงผลเป็นสัญลักษณ์ หรือ เป็นแถบสี จากนั้น เราต้องใส่ Code เพื่อให้ Code HTML นั้นถูกแสดงผลด้วยนะคะ โดยใส่ Code นี้ไว้ที่ Content Editor Web Part คะ โดยให้ใส่ที่ด้านล่างของ List ที่แสดงนะคะ

               งั้นมาดูขั้นตอนโดยละเอียดกันดีกว่าคะ
               1. ไปที่ List ที่ต้องการ เช่น Issue Tracking หรือ Task แล้วกด Settings
               2. กด Create Column เพื่อจะสร้าง Column แบบ Calculate Column
               3. ใส่ Column Name
               4. เลือก The type of information in this column เป็น
 แบบ Traffic light (actually a big bullet!):
                                    =”<DIV style=’font-weight:bold; font-size:24px; color:”&CHOOSE(RIGHT(LEFT
                                        (Priority,2),1),”red”,”orange”,”green”)&”;’>&bull;</DIV>”

                                – แบบ Indicator (reusing the default SharePoint KPI images):
                                    =”<DIV><IMG src=’/_layouts/images/KPIDefault-”&(3-RIGHT(LEFT(Priority,2),1))&
                                        ”.gif’ /></DIV>”

                                – แบบ Font color:
                                    =”<DIV style=’font-weight:bold; font-size:12px; color:”&CHOOSE(RIGHT(LEFT
                                        (Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”

                                – แบบ Background color:
                                    =”<DIV style=’font-size:12px; background-color:”&CHOOSE(RIGHT(LEFT
                                       (Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”

                6. กด OK                
                7. จากนั้น Add Web Part ที่ชื่อ Content Editor Web Part ลงไปที่หน้าที่แสดงผลของ List โดยไปที่
                      Site Actions > Edit Page
                8. กด Add a Web Part ที่ชื่อ  Content Editor Web Part ซึ่งอยู่ในหมวด Miscellaneous
                9. นำ  Content Editor Web Part ลากมาอยูตำแหน่งส่วนล่างของ List
             10. ที่ Content Editor Web Part กด edit > Modify Shared Web Part
             11. จะปรากฎหน้าต่างด้านขวา ให้เลือก Source Editor… และใส่ Code ด้านล่างลงไป เพื่อให้ Code ที่ใส่ในขั้นตอนที่ 5 
                    ได้ถูกแสดงผลเป็น HTML ได้อย่างถูกต้อง เพราะถ้าไม่อย่างนั้น Calculate Column  ที่ถูกเพิ่มเข้าไปก็จะแสดงใน
                     ส่วน Code เป็น Text ธรรมดา

<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>

             12. กด Save
             13. ในส่วน Layout  ให้ติ๊ก Hidden เพื่อซ่อน Content Editor Web Part นี้
             14. กด OK
             15. กด Exit Edit Mode ที่ด้านบนขวาของ Page

                     เท่านี้ก็เสร็จเรียบร้อยแล้วนะคะ นำไปประยุกต์ใช้กันได้เลยคะ และสำหรับสูตรที่ไว้ใช้ใน Formula ที่ไว้ใช้ใน Calculate Column สามารถไปดูรายละเอียดสูตรอื่นๆได้ที่นี่เลย >> คลิกๆ ที่นี่เลยจ๊ะ

credit : http://blog.pathtosharepoint.com/2008/09/01/apply-color-coding-to-your-sharepoint-lists/

ความเห็น
  1. witit พูดว่า:

    ผมลองทำตาม blog นี้แล้วก็ยังไม่สามารถทำได้ ซื้ง ยังเป็น =””&Priority&””
    เหมือนเดิมไม่มีไรเปลี่ยนแปลง

  2. Netty Pikunkaem พูดว่า:

    ลองตรวจสอบว่า ตำแหน่งของ Content Editor Web Part ที่ใส่โค๊ดเพื่อให้การแสดงผลเป็นแบบ HTML วางตำแหน่งล่างของ List หรือเปล่าคะ

    ถ้าไม่ได้อย่างไร แจ้งมาได้นะคะ จะได้แคปเจอร์หน้าจอโดยละเอียดให้คะ

  3. witit พูดว่า:

    ขอบพระคุณอย่างสูงครับ
    ตามที่คุณ Netty ได้แนะนำมาได้ลองนำ CEWP ไปวางตำแหน่งล่างของ list ก็ยังไม่ได้ ถ้าไม่เป็นการรบกวนขอความกรุณา ช่วย Capture หน้าจอ มาลองทำตามด้วยครับ

  4. ออย พูดว่า:

    คุณ Netty คะ
    รบกวนขอไฟล์ที่คุณ Netty ได้ capture หน้าจอส่งให้คุณ Witit ด้วยได้ไม๊คะ
    ลองทำตาม แล้วเจอปัญหาเดียวกันค่ะ คือ ยังขึ้นเป็น text อยู่

  5. tig พูดว่า:

    คุณ Netty คะ
    รบกวนขอไฟล์ที่คุณ Netty ได้ capture หน้าจอส่งให้คุณ Witit ด้วยได้ไม๊คะ
    ลองทำตาม แล้วเจอปัญหาเดียวกันค่ะ คือ ยังขึ้นเป็น text อยู่ ขอบคุณล่วงหน้าค่ะ

  6. Netty Pikunkam พูดว่า:

    รอรับทางเมล์ได้เลยนะคะ ^^

  7. kapeak พูดว่า:

    คุณ Netty
    ผม Test ทั้งวันเลย ทำไม่ได้ครับ อยากทำได้

    ส่งเมล์ให้หน่อยครับ ขอบพระคุณมากครับ

    • Netty Pikunkam พูดว่า:

      ต้องขออภัยทึ่ตอบกลับช้านะคะพอดีติดอบรมและงานด่วนทั้งอาทิตย์
      ไม่ทราบว่าทำได้หรือยังคะ. เดี๋ยวจะส่งเมล์ไปให้วันนี้นะคะ

      Netty

  8. prachum พูดว่า:

    คุณ Netty ครับ
    ผมรบกวนขอ File เหมือนกันครับ กำลังหัดทำเหมือนกันครับ

    ขอบคุณมาก ๆ ครับ

  9. วุธ พูดว่า:

    ทำไม่ได้เหมือนกันครับ รบกวนขอด้วยครับ

  10. วุธ พูดว่า:

    var theTBODYTDs = wrapDiv.getElementsByTagName(“TD”); var j=0; var TDContent = ” “;

    น่าจะขาดส่วนนี้อ่ะครับ

    • Netty Pikunkam พูดว่า:

      เอ่ เท่าที่ดู โค้ดก็มีบรรทัดนี้นะคะ เนตลองตรวจโดยก๊อปปี้จากหน้าเว็บเนตกับที่ส่งเมล์ไปให้ มันก็เหมือนกันนะ หรือว่าเนตตาลาย 55

  11. Netty Pikunkam พูดว่า:

    เท่าที่ดู sharepoint services 3.0 ไม่มี Indicator นะคะ อ้างอิงตาม http://www.dmcinfo.com/Services/SharePoint-Consulting-Services/SharePoint-Version-Selection.aspx

    • วุธ พูดว่า:

      คุณเนตครับผมอยากจะถามเรื่อง Workflow ของ Sharepoint services 3.0 หน่อยครับ มันต้องเริ่มยังไงบ้างและการใช้งานจะทำยังไงครับ พอดีผมลองสร้างแล้วมันงงอ่ะครับ รบกวนอีกนิดนึงครับ ขอบคุณมากๆครับ

  12. nungning พูดว่า:

    ทำไม่ได้ ค่ะ มันขึ้น ​ (1) High ช่วยด้วยน่ะคะ ขอบคุณคะ

  13. nungning พูดว่า:

    ลืมบอก คะ ใช้ sharepoint 2010

  14. free psychic พูดว่า:

    I like the helpful information yyou provide in your articles.

    I’ll bookmark your weblog and heck again here frequently.
    I am quite cettain I will learn lots of neew stuff
    right here! Best off luckk for the next!

  15. validity พูดว่า:

    Excellent, what a webpage it is! This website provides useful facts
    to us, keep it up.

  16. psychic predictions พูดว่า:

    We’re a group of volunteers and starting a new scheme in our
    community. Yourr site offered uus with valuable information to work on. You
    have done a formidable job and our whole community will be thankful to you.

  17. psychically พูดว่า:

    Good post. I learn something totally neww and challenging on blogs I stumbleupon every day.
    It will always be interesting to read through articles from other writers and practice something from other websites.

  18. mounts พูดว่า:

    I’ve learn a few jujst right stuff here. Definitely price bookmarking for revisiting.
    I surprise how so much effort you place to create this kind oof excellent informative website.

  19. article Writer for hire พูดว่า:

    Simply wish to say your article is as amazing. The clearness
    on your publish is just nice and that i could assume you arre an expert on this subject.
    Well together with your permission let me to clutch your
    RSS feed too stay up to date with approaching
    post. Thank you one million and please carry on the
    enjoyable work.

  20. bar พูดว่า:

    of course like your website but you have to test the spelling on quite a few of yor posts.
    A number oof them are rife with spelling problems and I find it very
    troublesome to teell the truth on the other hand I will definitely come again again.

  21. Wedding Spiritual Celebration พูดว่า:

    I like thhe valuable information you provide to your articles.
    I’ll bookmarkk your weblog and take a look at again here frequently.

    I’m fairly certain I will be told plenty of new stuff right right here!
    Good luck for thhe next!

ใส่ความเห็น