ใน 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”)&”;’>•</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 ธรรมดา
//
// 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/
[…] https://vipnetty.wordpress.com/2010/09/03/sharepoint_list_color/ Another translation, this time in Thai . […]
ผมลองทำตาม blog นี้แล้วก็ยังไม่สามารถทำได้ ซื้ง ยังเป็น =””&Priority&””
เหมือนเดิมไม่มีไรเปลี่ยนแปลง
ลองตรวจสอบว่า ตำแหน่งของ Content Editor Web Part ที่ใส่โค๊ดเพื่อให้การแสดงผลเป็นแบบ HTML วางตำแหน่งล่างของ List หรือเปล่าคะ
ถ้าไม่ได้อย่างไร แจ้งมาได้นะคะ จะได้แคปเจอร์หน้าจอโดยละเอียดให้คะ
ขอบพระคุณอย่างสูงครับ
ตามที่คุณ Netty ได้แนะนำมาได้ลองนำ CEWP ไปวางตำแหน่งล่างของ list ก็ยังไม่ได้ ถ้าไม่เป็นการรบกวนขอความกรุณา ช่วย Capture หน้าจอ มาลองทำตามด้วยครับ
เดี่ยวคืนนี้จะส่งทางเมล์ให้นะคะ ^^
ส่งทางเมล์ให้เรียบร้อยแล้วนะคะ ลองตรวจสอบดูคะ
คุณ Netty คะ
รบกวนขอไฟล์ที่คุณ Netty ได้ capture หน้าจอส่งให้คุณ Witit ด้วยได้ไม๊คะ
ลองทำตาม แล้วเจอปัญหาเดียวกันค่ะ คือ ยังขึ้นเป็น text อยู่
ได้คะคุณออย รอรับทางเมล์ได้เลยนะคะ
เนต
คุณ Netty คะ
รบกวนขอไฟล์ที่คุณ Netty ได้ capture หน้าจอส่งให้คุณ Witit ด้วยได้ไม๊คะ
ลองทำตาม แล้วเจอปัญหาเดียวกันค่ะ คือ ยังขึ้นเป็น text อยู่ ขอบคุณล่วงหน้าค่ะ
รอรับทางเมล์ได้เลยนะคะ ^^
คุณ Netty
ผม Test ทั้งวันเลย ทำไม่ได้ครับ อยากทำได้
ส่งเมล์ให้หน่อยครับ ขอบพระคุณมากครับ
ต้องขออภัยทึ่ตอบกลับช้านะคะพอดีติดอบรมและงานด่วนทั้งอาทิตย์
ไม่ทราบว่าทำได้หรือยังคะ. เดี๋ยวจะส่งเมล์ไปให้วันนี้นะคะ
Netty
คุณ Netty ครับ
ผมรบกวนขอ File เหมือนกันครับ กำลังหัดทำเหมือนกันครับ
ขอบคุณมาก ๆ ครับ
ส่งเมล์ให้แล้วนะคะ ลองดูคะ ^^
Netty
ทำไม่ได้เหมือนกันครับ รบกวนขอด้วยครับ
ส่งเมล์ให้แล้วนะคะ ลองดูนะคะ ^^
ได้แล้วนะครับ ท่าทาง code java script ที่ post ไว้จะผิดอ่ะครับ ถามอีกนิดนึงครับใน sharepoint services 3.0 ไม่มี indicator เหรอครับ เพราะผมลองใส่ไปดูมันไม่เห็นรูปอ่ะครับ
var theTBODYTDs = wrapDiv.getElementsByTagName(“TD”); var j=0; var TDContent = ” “;
น่าจะขาดส่วนนี้อ่ะครับ
เอ่ เท่าที่ดู โค้ดก็มีบรรทัดนี้นะคะ เนตลองตรวจโดยก๊อปปี้จากหน้าเว็บเนตกับที่ส่งเมล์ไปให้ มันก็เหมือนกันนะ หรือว่าเนตตาลาย 55
เท่าที่ดู sharepoint services 3.0 ไม่มี Indicator นะคะ อ้างอิงตาม http://www.dmcinfo.com/Services/SharePoint-Consulting-Services/SharePoint-Version-Selection.aspx
คุณเนตครับผมอยากจะถามเรื่อง Workflow ของ Sharepoint services 3.0 หน่อยครับ มันต้องเริ่มยังไงบ้างและการใช้งานจะทำยังไงครับ พอดีผมลองสร้างแล้วมันงงอ่ะครับ รบกวนอีกนิดนึงครับ ขอบคุณมากๆครับ
ขออภัยมากๆเลยคะ เนตเพิ่งเห็นคอมเมนท์ ><
ทำไม่ได้ ค่ะ มันขึ้น (1) High ช่วยด้วยน่ะคะ ขอบคุณคะ
ลืมบอก คะ ใช้ sharepoint 2010
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!
Excellent, what a webpage it is! This website provides useful facts
to us, keep it up.
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.
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.
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.
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.
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.
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!