Bar er enn nokkuð hár til Lengja mosa

Í dag, I was working with a client and describing how to modify the content query web part and display additional bits of information from a content type.

"First, þú stilla CQWP að tengja við gögn heimildum sínum, þá flytja það til vinnustöð, breyta <CommonViewFields>, hlaða, remove the original and now it’s ‘primed’ to display those other columns. Næsta, opna SharePoint Designer, navigate to the site collection root and locate ItemStyle.xsl. Copy one of the templates as a useful starting point. Go back and modify the CQWP to make use of this new template. Lokum, breyta sniðmát til að gera nýja reiti! (Ekki gleyma að athuga það aftur í svo að aðrir notendur geta séð niðurstöður)."

Það er allt alveg ljóst að mér (og flestir af okkur SharePoint verktaki tegundir) hvað er að gerast og hvernig það er alveg ágætur, í raun, that the data retrieval aspects of the CQWP are so well-separate from the data presentation aspects. En, það er ekki svo auðvelt að útskýra, er það?

<endir />

Technorati Tags: ,

Sýna efni Fyrirspurn Web Part uppgjör í töflu / Tafla

Yfirlit og Markmið

Út af the kassi, Moss’ Efni Fyrirspurn Web Part (CQWP) birtir uppgjör sitt á lista sniði, similar to search results. It is also possible to display the results in a grid format (i.e. HTML töflu snið). Grid formats are better in some circumstances. I describe how to achieve that effect in this article.

Viðskipti Atburðarás

I have worked with a client on an enterprise-wide MOSS rollout. We have designed their taxonomy such that projects are first class citizens in the hierarchy and have their own top level site. Project managers maintain a singleton list of project summary information, svo sem titil, fjárhagsáætlun, ráð verklok, remaining budget and other summary type fields. By "singleton" I mean a custom SharePoint list guaranteed to contain only one item. Simplistically, það lítur svona út:

mynd

Tæknilega nálgun er mikill the sami eins og lýst hér (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!447.entry). The CQWP uses an XSL transform to emit HTML for the browser to render.

I always envision the result before diving into the XSL because XSL is a nightmare. Here’s my desired result:

mynd

HTML svona býr að niðurstöðu:

<HTML>
 <líkami>
 <miðstöð>
 <borð landamæri= 1>

<!-- Merki ->
 <tr bgcolor= Blár>
 <td><letur litur= Hvítt><B>Project Name</B></letur></td>
 <td align= Rétt><letur litur= Hvítt><B>Ljúka Dagsetning</B></letur></td>
 <td align= Rétt><letur litur= Hvítt><B>Budget</B></letur></td>
 <td align= Rétt><letur litur= Hvítt><B>Raunveruleg kostnað</B></letur></td>
 <td><letur litur= Hvítt><B>Alls Status</B></letur></td>
 </tr>

<tr>
 <td>Re-vír tölvu herbergi.</td>
 <td align= Rétt>02/01/08</td>
 <td align= Rétt>22,500.00</td>
 <td align= Rétt>19,000.00</td>
 <td>Í vinnslu</td>
 </tr>

<tr>
 <td>Framlag netþjóna fyrir SQL Uppfærsla</td>
 <td align= Rétt>04/01/08</td>
 <td align= Rétt>7,500.00</td>
 <td align= Rétt>0.00</td>
 <td>Planned</td>
 </tr>

</borð>
 </miðstöð>
 </líkami>
</HTML>

Nálgun

Fylgdu þessum skrefum til að búa rist:

  1. Þekkja þá hluti af rist (raðir / dálka).
  2. Skilgreina og skapa nauðsynlegar dálka síða.
  3. Búa undir síður fyrir verkefni og Singleton lista.
  4. Bæta við CQWP á vefsíðu og stilla það til að leita að listum.
  5. Breyta XML í CQWP að safna upp frekari dálka.
  6. Breyta XSL til að búa til töflu.

I’m going to concentrate on number six. Numbers one through four are straight-forward and something that any CQWP user has already done. Number five has been well-documented by others including this exhaustive screen-shot laden article from MSDN hér (http://msdn2.microsoft.com/en-us/library/bb897399.aspx) og bloggið Heather Salómons hér (http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx).

Hnetur og boltar

Byrja og framkvæma skref eitt til fimm eins og á MSDN skjöl og greinar Heather Salómons.

Á þessum tímapunkti, þú bættir CQWP til síðu og þú hafa þinn <CommonViewFields> stillt eftir þörfum.

Eftir venjulega skrefum, Ég fæ þessar millistig niðurstöður:

1. Búa gerð efnis, a templatized custom list for that content type and two sites. Here is the content type:

mynd

Hér er síða uppbygging:

mynd

2. Bæta við CQWP eftir að búa verkefni undirvefsvæðum mínar og Singleton verkefnisins samantekt listi:

mynd

3. Bæta allar frekari upplýsingar sem ég vil í gegnum <CommonViewFields>:

        <eign nafn="CommonViewFields" tegund="band">Project_x0020_Name;Project_x0020_Expenses;Project_x0020_Status;Project_x0020_Start_x0020_Date;Project_x0020_End_x0020_Date;Project_x0020_Budget</eign>

Athugaðu að ég þurfti að halda öllum eignum reiti í einni línu eða það myndi ekki virka (CQWP myndi segja mér að fyrirspurn skilað engar vörur).

4. Á þessum tímapunkti, we’re ready to move beyond the MSDN article and flip on over to Heather Solomon’s article. Follow her steps starting near step #5 til að búa til sérsniðna / unghosted version of ItemStyle.xsl. I follow Heather’s advice, upp í gegnum skref 11 og fá þessir millistig niðurstöður:

4.1: Nafn XSL sniðmát mitt eftirfarandi:

<XSL:template name="Grid" match="Row[@Style=’Grid’]" mode="itemstyle">

Ég líka örlítið breytt henni leiðbeinandi <XSL:fyrir-hvern …> með því að bæta <br /> merkja að veita hreinni skráningu:

    <XSL:fyrir-hvern velja="@ *">
      P:<XSL:gildi-af velja="nafn()" /><br/>
    </XSL:fyrir-hvern>

4.2: Ég breyta vefur hluti, go to appearance and select my "Grid" stíl:

mynd

Sækja breytinguna og hér er útkoman:

mynd

Við sjáum af ofangreindu að reitir við viljum (Verkefnið nafn, kostnað, staða, o.fl.) are available for us to use when we emit the HTML. Not only that, but we see the names by which we must reference those columns in the XSL. Til dæmis, we reference Project Status as "Project_x005F_x0020_Name".

Á þessum tímapunkti, við víkja úr blogginu lyngi og frá herðum þessara risa, Ég bæta við eigin svolítið minn.

ContentQueryMain.xsl

ATHUGIÐ: Þegar að gera breytingar á bæði ContentQueryMain.xsl auk ItemStyle.xsl, þú þarft að athuga þær skrár aftur í áður en þú sjá áhrif af breytingum þínum.

Fyrir rist-gerð tilgangi, MOSS uses two different XSL files to produce the results we see from a CQWP. To generate the previous bit of output, we modified ItemStyle.xsl. MOSS actually uses another XSL file, ContentQueryMain.xsl to in conjunction with ItemStyle.xsl to generate its HTML. As its name implies, ContentQueryMain.xsl is the "main" XSL that controls the overall flow of translation. It iterates through all the found items and passes them one by one to templates in ItemStyle.xsl. We’ll modify ItemStyle.xsl to generate the open <borð> skipun á undan emitting fyrstu röðinni af gögnum og lokun <borð> tag after emitting the last row. To accomplish this, ContentQueryMain.xsl is modified to pass two parameters to our "grid" sniðmát í ItemStyle.xsl, "last row" and "current row". ItemStyle.xsl uses these to conditionally emit the necessary tags.

Notkun tækni Heather Salómons, we locate ContentQueryMain.xsl. It is located in the same place as ItemStyle.xsl. This screen shot should help:

mynd

Við þurfum að gera eftirfarandi breytingar:

  • Breyta í XSL sniðmát, "CallItemTemplate" that actually invokes our Grid template in ItemStyle.xsl. We will pass two parameters to the Grid template so that it will have the data it needs to conditionally generate opening and closing <borð> merki.
  • Modify another bit of ContentQueryMain.xsl that calls the "CallItemTemplate" to pass it a "LastRow" breytu þannig að LastRow má um að Grid sniðmát okkar.

Locate the template named "OuterTemplate.CallItemTemplate" auðkennd með streng:

  <XSL:sniðmát nafn="OuterTemplate.CallItemTemplate">

Settu alla sniðmát sem fylgir:

  <XSL:sniðmát nafn="OuterTemplate.CallItemTemplate">
    <XSL:Gildi nafn="CurPosition" />

    <!--
      Add the "LastRow" breytu.
      We only use it when the item style pass in is "Grid".
    -->
    <XSL:Gildi nafn="LastRow" />

    <XSL:velja>
      <XSL:þegar próf="@ Style = 'NewsRollUpItem'">
        <XSL:gilda-sniðmát velja="." ham="itemstyle">
          <XSL:með-Gildi nafn="EditMode" velja="$cbq_iseditmode" />
        </XSL:gilda-sniðmát>
      </XSL:þegar>
      <XSL:þegar próf="@ Style = 'NewsBigItem'">
        <XSL:gilda-sniðmát velja="." ham="itemstyle">
          <XSL:með-Gildi nafn="CurPos" velja="$CurPosition" />
        </XSL:gilda-sniðmát>
      </XSL:þegar>
      <XSL:þegar próf="@ Style = 'NewsCategoryItem'">
        <XSL:gilda-sniðmát velja="." ham="itemstyle">
          <XSL:með-Gildi nafn="CurPos" velja="$CurPosition" />
        </XSL:gilda-sniðmát>
      </XSL:þegar>

      <!--
              Pass núverandi stöðu og lastrow til itemstyle.xsl Grid sniðmát.
              ItemStyle.xsl mun nota það til að senda frá sér opna og loka <borð> merki.
      -->
      <XSL:þegar próf="@ Style = 'Tafla'">
        <XSL:gilda-sniðmát velja="." ham="itemstyle">
          <XSL:með-Gildi nafn="CurPos" velja="$CurPosition" />
          <XSL:með-Gildi nafn="Síðast" velja="$LastRow" />
        </XSL:gilda-sniðmát>
      </XSL:þegar>

      <XSL:annars>
        <XSL:gilda-sniðmát velja="." ham="itemstyle">
        </XSL:gilda-sniðmát>
      </XSL:annars>
    </XSL:velja>
  </XSL:sniðmát>

Athugasemdirnar lýsa tilgangi breytingar.

Auðvitað, the "OuterTemplate.CallItemTemplate" is itself called from another template. Locate that template by searching for this text string:

<XSL:sniðmát nafn="OuterTemplate.Body">

Fletta í gegnum leiðbeiningar á OuterTemplate.Body og settu LastRow breytu sem hér segir (sýndur sem athugasemd í skáletrun):

<XSL:kalla-sniðmát nafn="OuterTemplate.CallItemTemplate">
  <XSL:með-Gildi nafn="CurPosition" velja="$CurPosition" />
  <!-- Settu LastRow breytu. -->
  <XSL:með-Gildi nafn="LastRow" velja="$LastRow"/>
</XSL:kalla-sniðmát>

Eftir allt þetta, við loksins hefur það sett upp á réttan hátt þannig að ItemStyle.xsl okkar getur gefið frá sér <borð> Tags á réttum stað.

ItemStyle.Xsl

ATHUGIÐ: Aftur, athuga í ItemStyle.xsl eftir að gera neinar breytingar þannig að þú sjá áhrif af þessum breytingum.

Við höfum tvö verkefni hér:

  • Replace the entire Grid template. You can copy/paste from below.
  • Add some mumbo jumbo outside the template definition that enables "formatcurrency" template to work. (Þú getur sagt að ég hafi örlitla séð á XSL).

Fyrsta, ofarlega ItemStyle.xsl, bæta við þessa línu:

  <!-- Sumir muldra tröllvaxinn sem gerir okkur kleift að sýna bandarískt. mynt. -->
  <XSL:aukastaf-sniði nafn="starfsfólk" stafa="D" />

  <XSL:sniðmát nafn="Default" passa="*" ham="itemstyle">

Athugaðu að ég bætti það beint áður en <XSL:template name="Default" …> skýring.

Næsta, go back to our Grid template. Replace the entire Grid template with the code below. It is thoroughly commented, en ekki hika við að sendu mér tölvupóst eða leyfi athugasemdir á blogginu mínu ef þú hefur einhverjar spurningar.

  <XSL:sniðmát nafn="Rist" passa="Róður[@ Style = 'Tafla']" ham="itemstyle">

    <!--
      ContentMain.xsl fer CurPos og síðasta.
      Við notum þetta til skilyrðum losa opinn og loka <borð> merki.
    -->
    <XSL:Gildi nafn="CurPos" />
    <XSL:Gildi nafn="Síðast" />

    <!-- Eftirfarandi breytur eru óbreytt frá venjulegu ItemStyle.xsl -->
    <XSL:breytu nafn="SafeImageUrl">
      <XSL:kalla-sniðmát nafn="OuterTemplate.GetSafeStaticUrl">
        <XSL:með-Gildi nafn="UrlColumnName" velja="'ImageUrl'"/>
      </XSL:kalla-sniðmát>
    </XSL:breytu>
    <XSL:breytu nafn="SafeLinkUrl">
      <XSL:kalla-sniðmát nafn="OuterTemplate.GetSafeLink">
        <XSL:með-Gildi nafn="UrlColumnName" velja="'LinkUrl'"/>
      </XSL:kalla-sniðmát>
    </XSL:breytu>
    <XSL:breytu nafn="DisplayTitle">
      <XSL:kalla-sniðmát nafn="OuterTemplate.GetTitle">
        <XSL:með-Gildi nafn="Titill" velja="@ Titill"/>
        <XSL:með-Gildi nafn="UrlColumnName" velja="'LinkUrl'"/>
      </XSL:kalla-sniðmát>
    </XSL:breytu>
    <XSL:breytu nafn="LinkTarget">
      <XSL:ef próf="@ OpenInNewWindow = 'true'" >_blank</XSL:ef>
    </XSL:breytu>

    <!--
      Hér við skilgreinum breytu, "tableStart".  Þetta inniheldur HTML
      .  Athugið að ef CurPos = 1, það felur í sér HTML í cdata tag.
      Annars, það mun vera tómur.

      Verðmæti tableStart er emited hvert skipti ItemStyle er kallað í gegnum
      .
    -->
    <XSL:breytu nafn="tableStart">
      <XSL:ef próf="$CurPos = 1">
        <![CDATA[
        <Tafla border = 1>
          <tr bgcolor="blue">
            <td><font color="white"><B>Project Name</B></letur></td>
            <td align="right"><font color="white"><B>Ljúka Dagsetning</B></letur></td>
            <td align="right"><font color="white"><B>Budget</B></letur></td>
            <td align="right"><font color="white"><B>Raunveruleg kostnað</B></letur></td>
            <td><font color="white"><B>Alls Status</B></letur></td>
          </tr>
        ]]>
      </XSL:ef>
    </XSL:breytu>

    <!--
      Annar breytu, tableEnd skilgreinir einfaldlega borðið lokun tag.

      Eins og með tableStart, það er alltaf emited.  Þetta er ástæða þess að gildi þess er
      .
    -->
    <XSL:breytu nafn="tableEnd">
      <XSL:ef próf="$CurPos = $ Síðast">
        <![CDATA[ </borð> ]]>
      </XSL:ef>
    </XSL:breytu>

    <!--
      Alltaf losa innihald tableStart.  Ef þetta er ekki í fyrsta
      , þá vitum við gildi þess
      .

      Slökkva framleiðsla sleppi því þegar tableStart ekki autt, það
      .  Ef
      , it will generate
      stuff like "&lt;borð&GT;" instead of "<borð>".
    -->
    <XSL:gildi-af velja="$tableStart" disable-framleiðsla sleppi=""/>


    <tr>
      <!--
      P:Project_x005F_x0020_Name
      :Project_x005F_x0020_End_x005F_x0020_Date
      :Project_x005F_x0020_Budget
      :Project_x005F_x0020_Expenses
      :Project_x005F_x0020_Status
      -->
      <td>
        <XSL:gildi-af velja="@ Project_x005F_x0020_Name"/>
      </td>

      <td align="rétt">
        <XSL:gildi-af velja="@ Project_x005F_x0020_End_x005F_x0020_Date"/>
      </td>

      <td align="rétt">
        <XSL:kalla-sniðmát nafn="formatcurrency">
          <XSL:með-Gildi nafn="gildi" 
velja="@ Project_x005F_x0020_Budget"></XSL:með-Gildi> </XSL:kalla-sniðmát> </td> <td align="rétt"> <XSL:kalla-sniðmát nafn="formatcurrency"> <XSL:með-Gildi nafn="gildi" velja="@ Project_x005F_x0020_Expenses">
</XSL:með-Gildi> </XSL:kalla-sniðmát> </td> <td> <XSL:gildi-af velja="@ Project_x005F_x0020_Status"/> </td> <!-- Allar eftirfarandi er athugasemd út til að skýra hlutina. Hins, koma með það aftur og efni það inn í a <td> að sjá sína         . --> <!-- <div id="linkitem" class="item"> <XSL:if test="string-length($SafeImageUrl) != 0"> <div class="image-area-left"> <a href="{$SafeLinkUrl}" target="{$LinkTarget}"> <img class="image-fixed-width" src="{$SafeImageUrl}"
alt="{@ ImageUrlAltText}"/> </a> </div> </XSL:ef> <div class="link-item"> <XSL:kalla-sniðmát
name="OuterTemplate.CallPresenceStatusIconTemplate"/> <a href="{$SafeLinkUrl}"
target="{$LinkTarget}" title="{@ LinkToolTip}"> <XSL:value-of select="$DisplayTitle"/> </a> <div class="description"> <XSL:value-of select="@Description" /> </div> </div> </div>
--> </tr> <!-- Losa borðið lokun tag. Ef við erum ekki á síðustu röðinni, þetta mun vera autt. --> <XSL:gildi-af velja="$tableEnd" disable-framleiðsla sleppi=""/> </XSL:sniðmát> <XSL:sniðmát nafn="formatcurrency"> <XSL:Gildi nafn="gildi" velja="0" /> <XSL:gildi-af velja="snið-númer($gildi, "$DDD,DDD,DDD.DD", "staff")" /> </XSL:sniðmát>

Standard WSS / MOSS Gögn Entry Skjár styðja ekki Cascading falla-hæðir (eða annar innan frá samskiptum)

UPDATE (04/2008): Þessi mikli blogg sýnir góðan javascript byggir nálgun á þessu vandamáli: http://webborg.blogspot.com/2008/04/add-functions-and-events-to-sharepoint.html

UPDATE II: (04/2008): Þetta blogg útlit efnilegur og: http://www.cleverworkarounds.com/2008/03/13/free-mosswss-2007-web-part-hide-controls-via-javascript/

Nokkrum sinnum í viku, ef ekki daglega, forum users describe a requirement that would normally be met via cascading drop-downs. Til dæmis, Ég hef tvær falla niður eftirlit:

  • Listi yfir bandarískt. ríki
  • Listi yfir bandarískt. cities.

As responsible UI providers, we want it to operate like this:

  • Paul selects a U.S. state from the drop-down.
  • This causes the cities drop-down to filter only those cities that belong to the selected state.
  • Paul selects a city from this filtered list.

There is no out-of-the-box support for this feature. Í raun, there is no OOB support for any kind of direct intra-form communication. This includes programmatically hiding/enabling/disabling fields in response to field changes elsewhere on the form.

The real objective of this article to to describe possible solutions and these are the options as I know them:

  1. Develop a custom column type. As a custom-column-developer, you have full control over the "world" of that custom column. You can implement a cascading drop-down that way.
  2. Consider using workflow. In some cases, you want to automatically assign a value to field based on another field’s value. Í þessu tilviki, you would normally try to use a calculated column, but some times, it just won’t get the job done. SharePoint Designer workflow is a relatively administer-friendly alternative to dropping down into code and visual studio. If you go this route, be aware of the issue addressed by þessi grein (http://paulgalvin.spaces.live.com/blog/cns!CC1EDB3DAA9B8AA!405.entry).
  3. Event handlers: Like workflow, this is an after-the-fact solution. Your event handler is a .NET assembly (C #, VB.NET) to which SharePoint passes control. The object you develop has access to the data of the list (and the whole object model) and can do any needed calculation.
  4. Use SharePoint Designer to create custom entry forms. I don’t have direct experience with this approach, but I hear they are doing good things with NewForm.aspx these days 🙂
  5. Roll your own ASP.NET data entry function (as a stand-alone web page or as a web part) and use that instead.

If anyone knows other and/or better options, please post a comment and I’ll update the body of this post.

<endir />

Technorati Tags:

Já / Nei (kassann) sía í Content Fyrirspurn Web Part

To filter for a query for the Yes/No check box entitled "PG Milestone", stilla CQWP svona:

mynd

Þetta er annar einn af þeim augljós-einu sinni-þú-veist-það en harður-til-finna-að-svar-við spurningum: Hvernig á að sía á Já / Nei kassann með fyrirspurn innihald vefur hluti.

The first search result I find using the search term "filter yes/no content query web part" is flat out wrong, so I thought I’d put this up there and see if it can replace the incorrect result in typical search results.

It’s quite easy: True values = "1" and false values do not equal "1" (pretty retro, actually).

In the above example, I created site column of type "Yes/No (checkbox)" named "PG Milestone". I added it to a doc library, uploaded a few documents, set the value for a couple and tested it.

<endir />

Búa til Bar myndrit í SharePoint

Yfirlit:

(UPDATE 12/04/07: Við annað áhugavert auðlind í lok tengja við annað blog sem fjallar þetta um mjög áhugavert vefur hluti)

This blog entry describes how to create a bar graph in SharePoint. This works in both WSS and MOSS environments as it only depends upon the data view web part.

The overall approach is as follows:

  1. Create a list or document library that contains the data you want to graph.
  2. Place the associated document library / custom list onto a page and convert it to a data view web part (DVWP).
  3. Modify the DVWP’s XSL to generate HTML that shows as a graph.

Viðskipti Atburðarás / Setup:

I have created a custom list with the standard Title column and one additional column, "Status". This models (very simplistically) an "Authorization For Expense" scenario where the title represents the project and the Status a value from the list of:

  • Proposed
  • In Process
  • Stalled

The objective is to produce an interactive horizontal bar graph that shows these status codes.

I have populated the list and it looks like this:

mynd

Create Data View Web Part:

Create the DVWP by adding the custom list to a page (site page in my case) and follow the instructions hér (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).

In addition to simply creating the DVWP, we also need to set the paging property to show all available rows. Fyrir mig, this looks something like this:

mynd

Á þessum tímapunkti, I always close SPD and the browser. I then re-open the page using the browser. This avoids accidentally mucking up the web part layout on the page.

Modify the XSLT:

It’s now time to modify the XSLT.

I always use visual studio for this. (Sjá hér for an important note about intellisense that will help you a lot).

I create an empty project add four new files (replacing the words "Original" and "New" as appropriate):

  • Original.xslt
  • New.xslt
  • Original Params.xml
  • New Params.xml

Í mínu tilfelli, það lítur svona út:

mynd

Modify the web part and copy the params and XSL to the "Original" version in Visual Studio.

The objective here is to cause the XSL to transform the results we get back from the DVWP query into HTML that renders as a graph.

Í þessu skyni, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (To be clear, the following is simply an example; don’t type it or copy/paste into visual studio. I provide a full blow starting point for that later in the write-up). The following sample graph is rendered as per the HTML immediately following:

Sample Bar Graph

Corresponding HTML:

<HTML>
<líkami>
<miðstöð>
<table width=80%>
<tr><td><miðstöð>Horizontal Bar Graph</td></tr>
<tr>
<td align="center">
<table border="1" width=80%>
<tr>
<td width=10%>Open</td>
<td><table cellpadding="0" cellspacing="0" border=0 width=50%><tr bgcolor=red><td>&nbsp;</td></tr></borð></td>
</tr>
<tr>
<td width=10%>Closed</td>
<td><table cellpadding="0" cellspacing="0" border=0 width=25%><tr bgcolor=red><td>&nbsp;</td></tr></borð></td>
</tr>
<tr>
<td width=10%>Stalled</td>
<td><table cellpadding="0" cellspacing="0" border=0 width=25%><tr bgcolor=red><td>&nbsp;</td></tr></borð></td>
</tr>
</borð>
</td>
</tr>
</borð>
</líkami>
</HTML>

I used a dead simple approach to creating my bars by setting the background color of a row to "red".

The take-away here is this: Í lok, all we are doing is creating HTML with rows and columns.

Template XSLT:

I’ve copied the XSLT that generates a horizontal bar graph. It’s fairly well commented so I won’t add much here except for these notes:

  • I started with the default XSL that SharePoint Designer gave me when I first created the DVWP.
  • I was able to cut this down from SPD’s 657 lines to 166 lines.
  • I didn’t mess around with the parameters XML file (which is separate from the XSL and you’ll know what I mean when you go to modify the DVWP itself; there are two files you can modify). Hins, in order to simplify it, I did remove nearly all of them from the XSL. This means that if you want to make use of those parameters, you just need to add their variable definitions back to the XSL. That will be easy since you will have the original XSL variable definitions in your visual studio project.
  • You ought to be able to copy and paste this directly into your visual studio project. Þá, remove my calls and insert your own calls to "ShowBar".
  • The drill down works by creating an <a href> like this: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. Í fyrstu, I thought I would need to conform to a more complex format: http://server/List/AllItems.aspx?View={guid}&FilterField1=blah&FilterValue1=blah, but in my environment that is not necessary. The List’s URL is passed to us by SharePoint so this is quite easy to generalize.

Here it is:

<XSL:stílsíðu útgáfa="1.0" exclude-result-prefixes="rs z o s ddwrt dt msxsl" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:XSL="HTTP://www.w3.org/1999/XSL/Transform"
xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="HTTP://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:ASP="HTTP://schemas.microsoft.com/ASPNET/20" xmlns:ddwrt="HTTP://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:o="urn:schemas-microsoft-com:office" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns:ddwrt2="urn:frontpage:internal"
> <XSL:framleiðsla aðferð="HTML" undirlið="no" /> <XSL:aukastaf-sniði NaN="" /> <XSL:Gildi nafn="ListUrlDir"></XSL:Gildi> <!-- I need this to support a drill-down. --> <XSL:sniðmát passa="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:__designer=http://schemas.microsoft.com/WebParts/v2/DataView/designer xmlns:ASP="HTTP://schemas.microsoft.com/ASPNET/20"
> <XSL:breytu nafn="dvt_StyleName">Tafla</XSL:breytu> <XSL:breytu nafn="Rows" velja="/dsQueryResponse/Rows/Row" /> <XSL:breytu nafn="dvt_RowCount" velja="count($Rows)" /> <XSL:breytu nafn="IsEmpty" velja="$dvt_RowCount = 0" /> <XSL:breytu nafn="dvt_IsEmpty" velja="$dvt_RowCount = 0" /> <XSL:velja> <XSL:þegar próf="$dvt_IsEmpty"> There is no data to graph!<br/> </XSL:þegar> <XSL:annars> <!-- The interesting stuff begins here. We need to define a pair of variables for each row in the graph: total number of items and percent of total. --> <XSL:breytu nafn="totalProposed" velja="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Proposed'])" /> <XSL:breytu nafn="percentProposed" velja="$totalProposed div $dvt_RowCount" /> <XSL:breytu nafn="totalInProcess" velja="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'In Process'])" /> <XSL:breytu nafn="percentInProcess" velja="$totalInProcess div $dvt_RowCount" /> <XSL:breytu nafn="totalStalled" velja="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Stalled'])" /> <XSL:breytu nafn="percentStalled" velja="$totalStalled div $dvt_RowCount" /> <!-- We define our HTML table here. I'm borrowing from some standard SharePoint styles here to make it consistent. I think it will honor changes to the global css file as well as theme overrides. --> <borð breidd="100%" cellspacing="0" cellpadding="2" stíl="border-right: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0; border-left-style: solid; border-left-width: 1; border-top-style: solid; border-top-width: 1;"> <tr> <td align="miðstöð"> <borð landamæri="1" breidd="100%"> <!-- For each status that we want to graph, we call the "ShowBar" sniðmát. We pass it: 1. A label for the row. This is transformed into a hyperlink. 2. The percent (variable from above). 3. The actual field name of the code from the underlying list. This does not need to match the display label. 4. Field value matched for #3. 5. Total items of this status code (not the grand total of all status codes). It emits a <tr></tr> and the horizontal bar graph line. We call this template for each status code we want to view. --> <XSL:kalla-sniðmát nafn="ShowBar"> <XSL:með-Gildi nafn="BarDisplayLabel" velja="'Proposed'"/> <XSL:með-Gildi nafn="BarPercent" velja="$percentProposed"/> <XSL:með-Gildi nafn="QueryFilterFieldName" velja="'Status'"/> <XSL:með-Gildi nafn="QueryFilterFieldValue" velja="'Proposed'"/> <XSL:með-Gildi nafn="TotalItems" velja="$totalProposed"></XSL:með-Gildi> </XSL:kalla-sniðmát> <XSL:kalla-sniðmát nafn="ShowBar"> <XSL:með-Gildi nafn="BarDisplayLabel" velja="'Stalled'"/> <XSL:með-Gildi nafn="BarPercent" velja="$percentStalled"/> <XSL:með-Gildi nafn="QueryFilterFieldName" velja="'Status'"/> <XSL:með-Gildi nafn="QueryFilterFieldValue" velja="'Stalled'"/> <XSL:með-Gildi nafn="TotalItems" velja="$totalStalled"></XSL:með-Gildi> </XSL:kalla-sniðmát> <XSL:kalla-sniðmát nafn="ShowBar"> <XSL:með-Gildi nafn="BarDisplayLabel" velja="'In Process'"/> <XSL:með-Gildi nafn="BarPercent" velja="$percentInProcess"/> <XSL:með-Gildi nafn="QueryFilterFieldName" velja="'Status'"/> <XSL:með-Gildi nafn="QueryFilterFieldValue" velja="'In Process'"/> <XSL:með-Gildi nafn="TotalItems" velja="$totalInProcess"></XSL:með-Gildi> </XSL:kalla-sniðmát> </borð> </td> </tr> </borð> </XSL:annars> </XSL:velja> </XSL:sniðmát> <!-- This template does the work of displaying individual lines in the bar graph. You'll probably do most of your tweaking here. --> <XSL:sniðmát nafn="ShowBar"> <XSL:Gildi nafn="BarDisplayLabel" /> <!-- label to show --> <XSL:Gildi nafn="BarPercent"/> <!-- Percent of total. --> <XSL:Gildi nafn="QueryFilterFieldName"/> <!-- Used to jump to the query & filter --> <XSL:Gildi nafn="QueryFilterFieldValue"/> <!-- Used to jump to the query & filter --> <XSL:Gildi nafn="TotalItems" /> <!-- total count of this barlabel --> <tr> <!-- The bar label itself. --> <td flokki="ms-formbody" breidd="30%"> <!-- This next set of statements builds a query string that allows us to drill down to a filtered view of the underlying data. We make use of a few things here: 1. We can pass FilterField1 and FilterValue1 to a list to filter on a column. 2. SharePoint is passing a key parameter to us, ListUrlDir that points to the underlying list against which this DVWP is "running". Isn't XSL fun? --> <XSL:texta disable-framleiðsla sleppi=""> <![CDATA[<a href="]]></XSL:texta> <XSL:gildi-af velja="$ListUrlDir"/> <XSL:texta disable-framleiðsla sleppi=""><![CDATA[?FilterField1=]]></XSL:texta> <XSL:gildi-af velja="$QueryFilterFieldName"/> <XSL:texta disable-framleiðsla sleppi=""><![CDATA[&FilterValue1=]]></XSL:texta> <XSL:gildi-af velja="$QueryFilterFieldValue"/> <XSL:texta disable-framleiðsla sleppi=""><![CDATA[">]]></XSL:texta> <XSL:gildi-af velja="$BarDisplayLabel"/> <XSL:texta disable-framleiðsla sleppi=""><![CDATA[</a>]]></XSL:texta> <!-- The next bit shows some numbers in the format: "(total / % of total)" --> (<XSL:gildi-af velja="$TotalItems"/> / <!-- This creates a nice percent label for us. Takk, Microsoft! --> <XSL:kalla-sniðmát nafn="percentformat"> <XSL:með-Gildi nafn="percent" velja="$BarPercent"/> </XSL:kalla-sniðmát>) </td> <!-- Lokum, emit a <td> tag for the bar itself.--> <td> <borð cellpadding="0" cellspacing="0" landamæri="0" breidd="{round($BarPercent*100)+1}%"> <tr bgcolor="red"> <XSL:texta disable-framleiðsla sleppi=""><![CDATA[&nbsp;]]></XSL:texta> </tr> </borð> </td> </tr> </XSL:sniðmát> <!-- This is taken directly from some XSL I found in an MS template. --> <XSL:sniðmát nafn="percentformat"> <XSL:Gildi nafn="percent"/> <XSL:velja> <XSL:þegar próf="snið-númer($percent, '#,##0%;-#,##0%")= 'NaN'">0%</XSL:þegar> <XSL:annars> <XSL:gildi-af velja="snið-númer($percent, '#,##0%;-#,##0%")" /> </XSL:annars> </XSL:velja> </XSL:sniðmát> </XSL:stílsíðu>

The Results:

The XSL from above generates this graph:

mynd

Drill down to the underlying data by clicking on the status code:

mynd

Concluding Thoughts:

Can This Be Generalized?

I love this graphing concept, but I hate the fact that I have to go in and do so much hand-coding. I’ve given a little thought to whether it can be generalized and I’m optimistic, but I’m also a little fearful that there may be a brick wall somewhere along the path that won’t offer any work-around. If anyone has some good ideas on this, please make a note in the comments or email mig.

Vertical Graphs:

This is a horizontal bar graph. It’s certainly possible to create a vertical graph. We just need to change the HTML. I would start the same way: Create an HTML representation of a vertical bar graph and then figure out how to get that via XSL. If anyone is interested in that, I could be persuaded to try it out and work out the kinks. If someone has already done that, please let me know and I’ll gladly link to your blog 🙂

I think that challenge with a vertical graph is that the labels for the graph are more difficult to manage, but certainly not impossible.

Field Name Gotcha’s:

There are at least two things to look out for with your field names.

Fyrsta, a field name with a space has to be escaped in the XSL. This will probably be an issue here:

        <XSL:breytu nafn="totalProposed" 
velja="count(/dsQueryResponse/Rows/Row[normalize-space(@Status) = 'Proposed'])" />

If your "Status" column is actually named "Status Code" then you need to reference it as "Status_x0020_Code":

   <XSL:breytu nafn="totalProposed" 
velja="count(/dsQueryResponse/Rows/Row[normalize-space(@Status_x0020_Code) = 'Proposed'])" />

Annað, and I’m a little fuzzy on this, but you also need to be on the alert for field name changes. If you name your field "Status Code" and then later on, rename it to "AFE Status", the "internal name" does not change. The internal name will still be "Status Code" and must be referenced as "Status_x0020_Code". The "other resources" links may help diagnose and correct this kind of problem.

About that Color:

I picked "red" because it’s pleasing to me at the moment. It would not be a big deal to show different colors so as to provide more than just a visual description of a number, but to also provide a useful KPI. Til dæmis, if the percentage of "stalled" AFE’s is > 10% then show it red, otherwise show it in black. Nota <XSL:velja> to accomplish this.

Other Resources:

Happy transforming!

<endir />

Gerast áskrifandi að bloggið mitt!

SharePoint veitir ekki “Sem hefur aðgang” Skýrslur

UPDATE 01/28/08: Þetta Codeplex verkefni fjallar um þetta mál: http://www.codeplex.com/AccessChecker. I have not used it, en það lofar góðu ef þetta er mál sem þú þarft til að takast á í umhverfi þínu.

UPDATE 11/13/08: Joel Olesen skrifaði upp mjög góð staða á stærri öryggi stjórnun ræðir hér: HTTP://www.sharepointjoel.com / Listar / innlegg / Post.aspx?List=0cd1a63d-183c-4fc2-8320-ba5369008acb&ID = 113. It links to a number of other useful resources.

Forum notendur og viðskiptavinir spyrja oft spurning eftir þessum línum: "How do I generate a list of all users with access to a site" or "How can I automatically alert all users with access to list about changes made to the list?"

There is no out of the box solution for this. If you think about it for a moment, það er ekki erfitt að skilja hvers vegna.

SharePoint security is very flexible. There are at least four major categories of users:

  • Óskráðir notendur.
  • SharePoint Notendur og hópar.
  • Virkir notendur Listinn.
  • Eyðublöð byggt auðkenningar (FBA) notendur.

Sveigjanleiki þýðir að úr öryggi sjónarhorni, any given SharePoint site will be dramatically different from another. In order to generate an access list report, maður þarf að ganga úr skugga um hvernig staður er öruggur, query multiple different user profile repositories and then present it in a useful fashion. That’s a hard problem to solve generically.

Hvernig eru stofnanir takast á við þetta? I’d love to hear from you in comments or netfang.

</enda>

Technorati Tags: ,

Moss segir mér dálkheiti mín er áskilin eða við notkun … En það er ekki

UPDATE 12/04/07: Sjá þetta Microsoft KB (http://support.microsoft.com/kb/923589) fyrir frekari upplýsingar.

Reyndar, það kemur í ljós að það er, en tricksy MOSS þurfti að gera það erfitt.

My customer does some development work on his MOSS site over the weekend. It’s a bit of a jumble as to what he actually did, en niðurstaðan er þessi:

  • He tries to add a site column called "Quantity" og mosi Svör: "The column name that you entered is already in use or reserved. Choose another name."
  • He attempts to add it to another environment and that works. Því, "Quantity" er ekki frátekið heiti.
  • He tries to find an existing site column named "Quantity" in that site collection. He cannot find it.

Ég gerði nokkrar rannsóknir, and even some coding, efldist heimspeki og að lokum komist að því að dálkinum Magn en, í raun, exist. It was in the "_Hidden" group. Hence, við gátum ekki fundið það í gegnum SharePoint notendaviðmót.

Hvernig var það fá það? I do not know, en ég hef kenningu (eða eins og konan mín myndi kalla það, "blah blah blah"). Einhvers staðar meðfram línu, a stórkostlegur fjörutíu sniðmát was added and probably activated at a site in the site collection. It was then deactivated (eða staður fjarri). The site column, þó, remained but in the "_Hidden" group. If someone knows better, vinsamlegast láttu mig vita með netfang eða staða í athugasemdum.

SharePoint was telling the truth. It’s hardly worth pointing out that that message is not as helpful as it could be. It would be nice to see that message fork into two different messages in the future: 1) Segja að dálkur heiti er frátekið eða það er ekki. 2) Ef það er ekki áskilinn, sýna síðuna, eða að minnsta kosti að hópurinn, þar sem dálkurinn nafn er þegar í notkun.

</enda>

OM Núverandi gögn með Custom List (eða, Enn ein OM Gögn Displayor [eins Yacc, en mismunandi])

Í dag, I spent a handful of hours tracking down the root cause behind the message "The column name that you entered is already in use or reserved. Choose another name."

Súlan í viðkomandi gæti skapað, eytt og aftur búið í öðru umhverfi, so I knew it wasn’t a reserved name. Hins, I simply couldn’t find the column anywhere via the standard SharePoint user interface at any site in the site collection.

I posted to MSDN forums here and the indomitable Andrew Woodward pointed me in the direction of the underlying object model data.

I went off to codeplex to find some tools that would help me peer into the underlying OM data and help me locate the trouble.

I tried several tools and they were very cool and interesting but in the end, the UI wasn’t good enough for my purpose. I’m not criticizing them by any means, but clearly the tool-makers didn’t have my problem in mind when they created their UI :). Most people seem to be investing a fair amount of time and effort in creating workstation / client applications that provide tree views, right-click context menus and so forth. These are nice and all, but it’s a lot of work to create a top-of-the-line user experience that is also very flexible.

I really needed an answer to this problem. It occurred to me that if I could get all of the site columns in the site collection into a custom list, I could filter, sort and create views that would help me find this supposedly existing column (which it did, BTW). I went ahead and did that and an hour or two later, had all my site columns loaded into a custom list with grouping, sorting and so forth. I found my answer five minutes later.

If and when I successfully take over the world, I think I will decree that all SharePoint tools providers must seriously consider surfacing their object model data in a custom list. That way, I have the power to search any way I want (constrained, auðvitað, by standard sharepoint features).

SharePoint Designer Vinnuflæði Custom Action — Athugun Um <Field Tie Hönnuður Gerð =”StringBuilder” … />

Bara fljótur athugun að það er mjög mikilvægur munur á milli þessara tveggja skilgreininga:

<FieldBind Field = "InParam1" Hönnuður type = "String Builder" Id = "2" Texti = "Inntak breytu # 1" />

á móti:

<FieldBind Field = "InParam1" Id = "2" Texti = "Inntak breytu # 1" />

Fyrstu sýnir eins og þetta í SPD:

mynd

á meðan hið síðarnefnda sýnir svona:

mynd

I’m not sure how helpful these screen shots are but I put in the effort to make them so you have to view them 🙂

Athugun er þetta: StringBuilder gerir þér kleift að byggja upp band (augljóslega) með því að blanda saman band literals og workflow gögn (via the "Add Lookup" hnappinn í neðra vinstra horninu). When you use the Add Lookup button, it inserts a token in the form "[%tákn%]". When SharePoint invokes your custom action, (C # kóða í mínu tilfelli), SharePoint fer táknið sjálft, not the value of the token. If you use the default designer type (The second tegund), SharePoint stækkar táknið og fer raunverulegt verðmæti skapi til aðgerða þína.

StringBuilder = BAD, sjálfgefið hönnuður type = GOOD.

Auðvitað, that’s not what I really mean. Just don’t try and pass a parameter to your custom action when the designer type = StringBuilder. Use the default designer type and chain a StringBuilder to it up front if you need to build complex strings in your workflow (sem er tilviljun nákvæmlega hvað maður gerir til að búa til öflugt efni fyrir email aðgerð, en það er fyrirsögn á annan bloggfærslu, Har Har).

<endir />

Ótímabær Vinnuflæði Virkjun — A Non-læknis Lausn

UPDATE: Sjá þessa MSDN umræðu, sérstaklega síðustu færslu: http://forums.microsoft.com/MSDN/showpost.aspx?postid=2631057&siteid=1. It describes a condition that may short circuit this whole thing. In short, það getur verið eins einfalt og að minnsta kosti eitt af þeim sviðum sem nauðsynlegur.

Ég er með skjal bókasafn sem styður átta tegundir efnis.

I have a SharePoint Designer workflow that wants to calculate and assign a "reminder date" með því einfaldlega að draga 30 dagar frá öðrum dálki, "due date". This should only happen for one of the content types, "Insurance". The business objective is to produce a KPI that shows two categories of insurance documents: "about to expire" and "expired." (Þú getur lesið meira um þessa tegund af KPI og umfangsmeiri bora niður hér).

I have configured the workflow to fire when a new item is created and when an item is modified. The idea is that when an insurance document is uploaded, we calculate a "warning date" based on the expiration date. A pair of views work in connection with a KPI List to highlight these conditions when users hit their home page.

Þessi stefna virkar ekki þegar ég hlaða skjal.

I upload the document and I am presented with the meta data entry screen. Á þessum tímapunkti, I’m already in trouble. SharePoint has already, snemma frá sjónarhóli mínum, fired the workflow. I haven’t had a chance to pick the correct content type nor assign a due date. Á sama tíma, the workflow does not fire when I hit the submit button at this time. There’s some built-in logic that "believes" that first submit is part of the "create" event. Svo … workflow minn hefur rekinn og þegar hann framkvæma, it was passed default meta data values.

The best work-around I know of is to insert a "pause until" activity in the workflow. I have the workflow pause for 1 minute. While it’s pausing, Ég velja rétta gerð efnis, enter the meta data and submit. The pause completes and the workflow proceeds as needed. (Athugið að í umhverfi mínu, timer workflow activities from SPD do not work out of the box. You may have the same trouble. Sjá hér fyrir frekari upplýsingar).

I don’t like "magic delay" work-around. What happens if the user uploads a document and the phone rings and the ensuing conversation outlasts the pause? I can make the pause longer, en ég samt líkar það ekki.

Ég skrifaði um þetta á MSDN málþing hér: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2430725&SiteID=1