Параўнанне дат у вэб-частцы прадстаўлення дадзеныя для пабудовы KPI WSS

Увага: гэта было ўпершыню размешчаны на www.endusersharepoint.com тут: HTTP://www.endusersharepoint.com/2009/11/02/comparing-dates-in-a-data-view-web-part-to-build-a-wss-kpi-in-sharepoint/.

This is yet another blog post on comparing dates in XSL in a data view web part in SharePoint.

This is my scenario:

  • I have a custom list.
  • The business purpose of the list is to support the idea of a new employee and his/her tasks to be completed within 7 days of starting the job.
  • They are in a “warning zone” after 4 days if they have not completed these tasks.
  • I want to create a simple dashboard that shows green when they have either completed the task or if they have more than 4 days to complete it.
  • I want the dashboard to show yellow if they are in the warning zone.
  • I want to to show red if they have not completed the task after the due date.

I borrowed from гэтая артыкул ў Marc Anderson’s блог (http://mdasblog.wordpress.com/2008/02/19/comparing-dates-in-sharepoint-using-xsl/) to get the comparison logic and гэтая артыкул ў www.endusersharepoint.com for the basic ideas behind the dashboard (http://www.endusersharepoint.com/2008/12/09/visual-indicators-for-the-masses-kpis-in-wss/) written by Toni Frankola.

You should read the supporting blogs, but the implementation goes like this:

  1. Стварыць тып кантэнту (слупкі + CT)
  2. Create a custom list and associate it with the content type.
  3. Create a web part page.
  4. Add the custom list to the web part page.
  5. Open up the page in SPD.
  6. Convert the list to a DVWP.
  7. Modify the XSL to generate the dashboard bits.

I have two dates: a warning date and a due date. To compare the dates, my xsl does the following:

 
 <XSL:выбіраць>
 
 <!-- When both handbook and policy are signed, we are green regardless of dates. -->
 <XSL:калі тэст="@Employee_x0020_Handbook_x003F_ = 1 and @Security_x0020_Policies = 1">
 <IMG SRC="/_layouts/images/KPIDefault-0.GIF" стары="No problems"/>
 <a HREF="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ID}&ампер;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</a>
 </XSL:калі>
 
 <!-- Show amber indicator if we're past the warning date. -->
 <XSL:калі тэст="ddwrt:FormatDateTime(радок(DDWRT:Сёння()), 1033, 'yyyyMMdd') &GT;= ddwrt:FormatDateTime(радок(@TaskDueDate), 1033, 'yyyyMMdd')">
 <IMG SRC="/_layouts/images/KPIDefault-2.GIF" стары="Overdue"/>
 <a стыль="border: 0px" HREF="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ID}&ампер;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</a>
 </XSL:калі>
 
 <!-- Show red indicator if we're passed the due date. -->
 <XSL:калі тэст="ddwrt:FormatDateTime(радок(DDWRT:Сёння()), 1033, 'yyyyMMdd') &GT;= ddwrt:FormatDateTime(радок(@Warning_x0020_Date), 1033, 'yyyyMMdd')">
 <IMG SRC="/_layouts/images/KPIDefault-1.GIF" стары="Warning"/> 
 <a HREF="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ID}&ампер;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</a>
 </XSL:калі>
 
 <!-- If we get here, we're earlier than the warning date, so we're green. -->
 <XSL:у адваротным выпадку>
 <IMG SRC="/_layouts/images/KPIDefault-0.GIF" стары="No problems"/>
 <a HREF="/HumanResources/Lists/New Employee Checklist/EditForm.aspx?ID={@ID}&ампер;Source=/HumanResources/Shared Documents/New Hire Dashboard.aspx"> [Edit]</a>
 </XSL:у адваротным выпадку>
 
 </XSL:выбіраць>

A few key points from above:

  • I tried to compare dates without using the ddwrt functionality and got nowhere. I still don’t understand that. They dates displayed correctly, but both “>” and “<” comparisons always failed. У рэшце рэшт, DDWRT прыйшоў мне на дапамогу (дзякуй, зноў, Выціскання).
  • Я таксама адлюстравання [Edit] link to the item. I mainly did this so that I could easily test this out. The link itself may be useful to someone trying to figure it out.
  • Усё гэта рэалізуецца ў SharePoint Online і працуе добра.
  • Малюнкамі я спасылку ў каталогу _layouts (/_layouts / фота / KPI ...) даступныя з скрынкі ў маім асяроддзі так што яны, верагодна, даступна для вас, а.

Вось здымак экрана, як гэта выглядае для мяне:

image

</канец>

Падпісацца на мой блог.

Выконвайце за мной на Twitter у http://www.twitter.com/pagalvin

Пакінуць каментар

Ваш электронны адрас не будзе апублікаваны. Абавязковыя палі пазначаныя * *