jamii Archives: SharePoint Maendeleo

Jihadharini Mabadiliko Breaking kwa ItemStyle.xsl

Nilikuwa kazi na ItemStyle.xsl Customize ya kuangalia ya Sehemu ya Content Query Mtandao na haki juu ya wakati chakula cha mchana, I made a breaking change to the xsl. I didn’t realize it, but this had far reaching effects throughout the site collection. I went off to lunch and upon my return, niliona ujumbe huu kuonekana katika rundo la maeneo:

Haiwezi kuonyesha Sehemu hii Mtandao. Troubleshoot tatizo, kufungua ukurasa huu mtandao katika Windows SharePoint mhariri Huduma-sambamba HTML kama vile Microsoft Office SharePoint Designer. Kama tatizo litaendelea, kuwasiliana yako Web server msimamizi.

Ninamlaumu mteja (si kutambua kama bado kwamba ilikuwa ni kosa langu katika hatua hii) but eventually noticed that visual studio intellisense was warning me that I had malformed XSL. I corrected it and everything started working.

Kuwa darned makini wakati wa kufanya kazi na ItemStyle.xsl (na yoyote ya mafaili kimataifa XSL) — kuvunja yao huathiri mabaki wengi katika ukusanyaji tovuti.

<mwisho />

Kuonyesha Content Query Results Sehemu Web katika Grid / Meza

Overview na Lengo

Nje ya boksi, Moss’ Content Query Mtandao Sehemu ya (CQWP) maonyesho ya matokeo yake katika muundo wa orodha, similar to search results. It is also possible to display the results in a grid format (i.e. HTML meza format). Grid formats are better in some circumstances. I describe how to achieve that effect in this article.

Biashara Igizo

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, kama vile jina, bajeti, inatarajiwa kukamilika tarehe, remaining budget and other summary type fields. By "singleton" I mean a custom SharePoint list guaranteed to contain only one item. Simplistically, inaonekana kama hii:

picha

mbinu ya kiufundi ni nyingi sawa kama ilivyoelezwa hapa (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:

picha

HTML kama hii inazalisha kwamba matokeo:

<html>
 <mwili>
 <kituo cha>
 <meza mpaka= 1>

<!-- Labels ->
 <tr Bgcolor= Blue>
 <td><ni Michezo= Nyeupe><b>Mradi Jina</b></ni></td>
 <td align= Haki><ni Michezo= Nyeupe><b>Kukamilisha Tarehe</b></ni></td>
 <td align= Haki><ni Michezo= Nyeupe><b>Bajeti ya</b></ni></td>
 <td align= Haki><ni Michezo= Nyeupe><b>Gharama halisi</b></ni></td>
 <td><ni Michezo= Nyeupe><b>Hali ya jumla ya</b></ni></td>
 </tr>

<tr>
 <td>Re-waya chumba cha kompyuta.</td>
 <td align= Haki>02/01/08</td>
 <td align= Haki>22,500.00</td>
 <td align= Haki>19,000.00</td>
 <td>Katika Maendeleo</td>
 </tr>

<tr>
 <td>Utoaji servrar kwa Upgrade SQL</td>
 <td align= Haki>04/01/08</td>
 <td align= Haki>7,500.00</td>
 <td align= Haki>0.00</td>
 <td>Planned</td>
 </tr>

</meza>
 </kituo cha>
 </mwili>
</html>

Mbinu

Fuata hatua hizi ili kujenga gridi ya taifa:

  1. Kutambua vipengele wa gridi ya taifa (safu / nguzo).
  2. Kuainisha na kujenga nguzo muhimu tovuti.
  3. Kujenga maeneo ndogo kwa ajili ya miradi na orodha Singleton.
  4. Kuongeza CQWP ukurasa wa mtandao na configure ni kutafuta orodha yako.
  5. Kurekebisha XML CQWP wa kukusanya up nguzo ya ziada.
  6. Kurekebisha XSL kuzalisha meza.

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 hapa (http://msdn2.microsoft.com/en-us/library/bb897399.aspx) na blog Heather wa Solomoni hapa (http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx).

Na karanga Bolts

Kuanza na kutekeleza hatua moja kwa njia ya tano kama kwa nyaraka MSDN na makala Heather wa Solomoni.

Katika hatua hii, ve aliongeza CQWP yako ya ukurasa na una yako <CommonViewFields> kimeundwa kama ni muhimu.

Kufuatia hatua kawaida, Mimi kupata matokeo haya ya kati:

1. Kujenga aina ya maudhui, a templatized custom list for that content type and two sites. Here is the content type:

picha

Hapa ni muundo wa tovuti:

picha

2. Kuongeza CQWP baada ya kujenga mradi subsites yangu na orodha ya mradi Singleton muhtasari:

picha

3. Kuongeza taarifa yote ya ziada nataka kupitia <CommonViewFields>:

        <mali jina="CommonViewFields" aina="string">Project_x0020_Name;Project_x0020_Expenses;Project_x0020_Status;Project_x0020_Start_x0020_Date;Project_x0020_End_x0020_Date;Project_x0020_Budget</mali>

Kumbuka kuwa nilikuwa na kuweka mashamba yote mali kwa line moja au itakuwa si kazi (CQWP bila kuniambia kuwa hoja akarudi vitu hakuna).

4. Katika hatua hii, 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 kujenga customized / unghosted version of ItemStyle.xsl. I follow Heather’s advice, juu kupitia hatua 11 na kupata matokeo haya ya kati:

4.1: Jina langu XSL template kama ifuatavyo:

<xsl:template jina = "Grid" mechi = "Row[@Style=’Grid’]" mode = "itemstyle">

Mimi pia kidogo kurekebisha yake alipendekeza <xsl:kwa-kila …> kwa kuongeza <br /> kumtambulisha kutoa orodha safi:

    <xsl:kwa-kila kuchagua="@ *">
      P:<xsl:thamani ya kuchagua="jina()" /><br/>
    </xsl:kwa-kila>

4.2: Mimi kurekebisha sehemu mtandao, kwenda kuonekana na kuchagua yangu "Grid" style:

picha

Kuomba mabadiliko na hapa ni matokeo:

picha

Tunaweza kuona kutoka juu kwamba mashamba tunataka (Mradi jina, gharama, hadhi, nk) 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. Kwa mfano, sisi rejea Mradi Hali kama "Project_x005F_x0020_Name".

Katika hatua hii, sisi kuondoka blog Heather na kutoka mabega ya makubwa haya, Mimi kuongeza kidogo yangu kidogo.

ContentQueryMain.xsl

NOTE: Wakati wa kufanya mabadiliko ya ContentQueryMain.xsl wote kama vile ItemStyle.xsl, haja ya kuangalia files kurejesha kabla ya kuona athari za mabadiliko yako.

Kwa ajili ya gridi ya maamuzi madhumuni, 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 ni kuu "" 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 <meza> tag kabla kutotoa moshi safu ya kwanza ya data na kufunga <meza> tag after emitting the last row. To accomplish this, ContentQueryMain.xsl ni iliyopita kwa kupitisha vigezo mbili katika gridi ya taifa yetu "" template katika ItemStyle.xsl, "Mwisho mstari" and "current row". ItemStyle.xsl uses these to conditionally emit the necessary tags.

Kutumia mbinu Heather wa Solomoni, we locate ContentQueryMain.xsl. It is located in the same place as ItemStyle.xsl. This screen shot should help:

picha

Tunahitaji kufanya marekebisho yafuatayo:

  • Kurekebisha template xsl, "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 <meza> tags.
  • Kurekebisha mwingine kidogo ya ContentQueryMain.xsl kwamba wito CallItemTemplate "" kupita ni LastRow "" parameter ili LastRow wanaweza kufikishwa kwa Grid template wetu.

Machapisho template aitwaye "OuterTemplate.CallItemTemplate" kutambuliwa na kamba:

  <xsl:template jina="OuterTemplate.CallItemTemplate">

Kuchukua nafasi ya template nzima kama ifuatavyo:

  <xsl:template jina="OuterTemplate.CallItemTemplate">
    <xsl:kuacha jina="CurPosition" />

    <!--
      Kuongeza LastRow "" parameter.
      Sisi tu kutumia wakati style bidhaa kupita katika ni "Grid".
    -->
    <xsl:kuacha jina="LastRow" />

    <xsl:kuchagua>
      <xsl:wakati mtihani="@ Sinema = 'NewsRollUpItem'">
        <xsl:kuomba templates- kuchagua="." mode="itemstyle">
          <xsl:na-param jina="EditMode" kuchagua="$cbq_iseditmode" />
        </xsl:kuomba templates->
      </xsl:wakati>
      <xsl:wakati mtihani="@ Sinema = 'NewsBigItem'">
        <xsl:kuomba templates- kuchagua="." mode="itemstyle">
          <xsl:na-param jina="CurPos" kuchagua="$CurPosition" />
        </xsl:kuomba templates->
      </xsl:wakati>
      <xsl:wakati mtihani="@ Sinema = 'NewsCategoryItem'">
        <xsl:kuomba templates- kuchagua="." mode="itemstyle">
          <xsl:na-param jina="CurPos" kuchagua="$CurPosition" />
        </xsl:kuomba templates->
      </xsl:wakati>

      <!--
              Kupita nafasi ya sasa na lastrow kwa template itemstyle.xsl Grid.
              ItemStyle.xsl kutumia kwamba emit wazi na kufunga <meza> tags.
      -->
      <xsl:wakati mtihani="@ Sinema = 'Grid'">
        <xsl:kuomba templates- kuchagua="." mode="itemstyle">
          <xsl:na-param jina="CurPos" kuchagua="$CurPosition" />
          <xsl:na-param jina="Mwisho" kuchagua="$LastRow" />
        </xsl:kuomba templates->
      </xsl:wakati>

      <xsl:vinginevyo>
        <xsl:kuomba templates- kuchagua="." mode="itemstyle">
        </xsl:kuomba templates->
      </xsl:vinginevyo>
    </xsl:kuchagua>
  </xsl:template>

maoni kuelezea madhumuni ya mabadiliko.

Bila shaka, OuterTemplate.CallItemTemplate "" is itself called from another template. Locate that template by searching for this text string:

<xsl:template jina="OuterTemplate.Body">

Kitabu kupitia maelekezo katika OuterTemplate.Body na kuingiza parameter LastRow kama ifuatavyo (umeonyesha kama maoni katika italics):

<xsl:wito-template jina="OuterTemplate.CallItemTemplate">
  <xsl:na-param jina="CurPosition" kuchagua="$CurPosition" />
  <!-- Ingiza parameter LastRow. -->
  <xsl:na-param jina="LastRow" kuchagua="$LastRow"/>
</xsl:wito-template>

Baada ya huu, sisi hatimaye kuwa mambo kuweka vizuri ili ItemStyle.xsl yetu inaweza emit <meza> tags katika mahali sahihi na.

ItemStyle.Xsl

NOTE: Tena, kuangalia katika ItemStyle.xsl baada ya kufanya mabadiliko yoyote ili kuona athari ya mabadiliko hayo.

Tuna kazi mbili hapa:

  • Replace the entire Grid template. You can copy/paste from below.
  • Kuongeza baadhi ya jumbo Mumbo nje ufafanuzi template kwamba inawezesha "formatcurrency" template to work. (Unaweza kuwaambia kwamba mimi kushughulikia tenuous juu XSL).

Kwanza, karibu na juu ya ItemStyle.xsl, kuongeza mstari huu:

  <!-- Baadhi ya jumbo Mumbo kwamba unatuwezesha kuonyesha U.S. sarafu. -->
  <xsl:decimal-format jina="wafanyakazi" tarakimu="D" />

  <xsl:template jina="Default" mechi="*" mode="itemstyle">

Kumbuka kwamba mimi aliongeza ni moja kwa moja kabla ya <xsl:template jina = "Default" …> ufafanuzi.

Ijayo, go back to our Grid template. Replace the entire Grid template with the code below. It is thoroughly commented, lakini usisite kunitumia email au kuacha maoni kwenye blog yangu kama una maswali.

  <xsl:template jina="Gridi ya taifa" mechi="Row[@ Sinema = 'Grid']" mode="itemstyle">

    <!--
      ContentMain.xsl hupita CurPos na wa mwisho.
      Sisi kutumia haya masharti emit wazi na kufunga <meza> tags.
    -->
    <xsl:kuacha jina="CurPos" />
    <xsl:kuacha jina="Mwisho" />

    <!-- vigezo zifuatazo unmodified kutoka ItemStyle.xsl kiwango -->
    <xsl:variable jina="SafeImageUrl">
      <xsl:wito-template jina="OuterTemplate.GetSafeStaticUrl">
        <xsl:na-param jina="UrlColumnName" kuchagua="'ImageUrl'"/>
      </xsl:wito-template>
    </xsl:variable>
    <xsl:variable jina="SafeLinkUrl">
      <xsl:wito-template jina="OuterTemplate.GetSafeLink">
        <xsl:na-param jina="UrlColumnName" kuchagua="'LinkUrl'"/>
      </xsl:wito-template>
    </xsl:variable>
    <xsl:variable jina="DisplayTitle">
      <xsl:wito-template jina="OuterTemplate.GetTitle">
        <xsl:na-param jina="Title" kuchagua="@ Title"/>
        <xsl:na-param jina="UrlColumnName" kuchagua="'LinkUrl'"/>
      </xsl:wito-template>
    </xsl:variable>
    <xsl:variable jina="LinkTarget">
      <xsl:kama mtihani="@ OpenInNewWindow = 'kweli'" >_blank</xsl:kama>
    </xsl:variable>

    <!--
      Hapa sisi define variable, "TableStart".  Hii ina HTML
      .  Kumbuka kwamba kama CurPos = 1, ni pamoja na HTML katika tag CDATA.
      Vinginevyo, itakuwa tupu.

      thamani ya tableStart ni emited ItemStyle kila wakati inaitwa kupitia
      .
    -->
    <xsl:variable jina="tableStart">
      <xsl:kama mtihani="$CurPos = 1">
        <![CDATA[
        <meza mpaka = 1>
          <tr Bgcolor = "blue">
            <td><font Michezo = "nyeupe"><b>Mradi Jina</b></ni></td>
            <td align = "haki"><font Michezo = "nyeupe"><b>Kukamilisha Tarehe</b></ni></td>
            <td align = "haki"><font Michezo = "nyeupe"><b>Bajeti ya</b></ni></td>
            <td align = "haki"><font Michezo = "nyeupe"><b>Gharama halisi</b></ni></td>
            <td><font Michezo = "nyeupe"><b>Hali ya jumla ya</b></ni></td>
          </tr>
        ]]>
      </xsl:kama>
    </xsl:variable>

    <!--
      Mwingine variable, tableEnd tu amefafanua meza kufunga tag.

      Kama na tableStart, inazidi daima emited.  Hii ni kwa nini thamani yake ni
      .
    -->
    <xsl:variable jina="tableEnd">
      <xsl:kama mtihani="$CurPos = $ Mwisho">
        <![CDATA[ </meza> ]]>
      </xsl:kama>
    </xsl:variable>

    <!--
      Daima emit yaliyomo ya tableStart.  Kama hii si mara ya kwanza
      , basi tunajua thamani yake
      .

      Lemaza pato kukimbia kwa sababu wakati tableStart kuwa si tupu, ni
      .  Kama
      , itakuwa kuzalisha&lt;meza&gt;" badala ya "<meza>".
    -->
    <xsl:thamani ya kuchagua="$tableStart" Disable-pato-kukimbia="ndiyo"/>


    <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:thamani ya kuchagua="@ Project_x005F_x0020_Name"/>
      </td>

      <td align="haki">
        <xsl:thamani ya kuchagua="@ Project_x005F_x0020_End_x005F_x0020_Date"/>
      </td>

      <td align="haki">
        <xsl:wito-template jina="formatCurrency">
          <xsl:na-param jina="thamani" 
kuchagua="@ Project_x005F_x0020_Budget"></xsl:na-param> </xsl:wito-template> </td> <td align="haki"> <xsl:wito-template jina="formatCurrency"> <xsl:na-param jina="thamani" kuchagua="@ Project_x005F_x0020_Expenses">
</xsl:na-param> </xsl:wito-template> </td> <td> <xsl:thamani ya kuchagua="@ Project_x005F_x0020_Status"/> </td> <!-- Yote ya yafuatayo ni maoni nje kufafanua mambo. Hata hivyo, kuleta kwa nyuma na mambo ya kuwa katika <td> kuona wake         . --> <!-- <div id = "linkitem" darasa = "item"> <xsl:kama mtihani = "string-urefu($SafeImageUrl) != 0 "> <div darasa = "SafeImageUrleft"> <href = "{$SafeLinkUrl}" lengo = "{$LinkTarget}"> <img darasa = "image-fasta-width src = "" src="{$SafeImageUrl}"
alt = "{@ ImageUrlAltText}"/> </a> </div> </xsl:kama> <div darasa = "link-item"> <xsl:wito-template
name="OuterTemplate.CallPresenceStatusIconTemplate"/> <href = "{$SafeLinkUrl}"
lengo = "{$LinkTarget}" title = "{@ LinkToolTip}"> <xsl:thamani ya kuchagua = "$ DisplayTitle" /> </a> <div darasa = "maelezo"> <xsl:thamani ya kuchagua = "@ Description" /> </div> </div> </div>
--> </tr> <!-- Emit meza kufunga tag. Kama sisi si juu ya mstari wa mwisho, hii itakuwa tupu. --> <xsl:thamani ya kuchagua="$tableEnd" Disable-pato-kukimbia="ndiyo"/> </xsl:template> <xsl:template jina="formatCurrency"> <xsl:kuacha jina="thamani" kuchagua="0" /> <xsl:thamani ya kuchagua='format-idadi($thamani, "$ DDD,DDD,DDD.DD ", "Mfanyakazi")' /> </xsl:template>

Standard WSS / Moss Data Entry skrini Je Si Support kuachia Drop Downs- (au nyingine kutoka ndani ya mawasiliano)

UPDATE (04/2008): Hii kubwa blog kuingia inaonyesha nzuri javascript makao mbinu ya tatizo hili: http://webborg.blogspot.com/2008/04/add-functions-and-events-to-sharepoint.html

UPDATE II: (04/2008): Kuingia hii blog inaonekana kuahidi pamoja: http://www.cleverworkarounds.com/2008/03/13/free-mosswss-2007-web-part-hide-controls-via-javascript/

Mara kadhaa kwa wiki, kama si kila siku, forum users describe a requirement that would normally be met via cascading drop-downs. Kwa mfano, I have mbili udhibiti kuacha chini:

  • Orodha ya U.S. mataifa
  • Orodha ya U.S. 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. Kwa kweli, 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. Katika kesi hiyo, 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 makala hii (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, lakini nasikia wanafanya mambo mazuri na NewForm.aspx siku hizi 🙂
  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.

<mwisho />

Tags technorati:

Kujenga Diagram Bar katika SharePoint

Overview:

(UPDATE 12/04/07: Aliongeza mwingine rasilimali ya kuvutia mwishoni kuunganisha na mwingine blog kuwa anwani hii kupitia sehemu ya kuvutia sana mtandao)

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.

mbinu jumla ni kama ifuatavyo:

  1. Kuunda orodha au maktaba ya hati ambayo ina data unataka graph.
  2. Nafasi ya kuhusishwa hati maktaba / desturi orodha kwenye ukurasa na kubadili mtazamo wa data sehemu ya mtandao (DVWP).
  3. Kurekebisha DVWP ya XSL kuzalisha HTML kwamba inaonyesha kama graph.

Biashara Igizo / Kuanzisha:

I have umba orodha desturi na safu ya kiwango Kichwa na safu moja ya ziada, "Status". This models (sana simplistically) an "Authorization For Expense" mazingira ambapo cheo inawakilisha mradi na Hali ya thamani kutoka kwenye orodha ya:

  • Mapendekezo
  • Katika Mchakato
  • Umesitishwa

Lengo ni kuzalisha maingiliano usawa bar graph inaonyesha kwamba kanuni hizi hali ya.

Mimi wakazi orodha na inaonekana kama hii:

picha

Kujenga Takwimu View Mtandao Sehemu ya:

Kujenga DVWP kwa kuongeza orodha desturi ya ukurasa (tovuti ukurasa katika kesi yangu) na kufuata maelekezo hapa (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).

Mbali na tu kujenga DVWP, we also need to set the paging property to show all available rows. Kwa ajili yangu, hii inaonekana kitu kama hiki:

picha

Katika hatua hii, 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.

Kurekebisha XSLT:

Ni wakati sasa wa kurekebisha XSLT.

I always use visual studio for this. (Kuona hapa kwa kumbuka muhimu kuhusu Intellisense kwamba itasaidia mengi).

Mimi kujenga mradi tupu kuongeza wanne faili jipya (replacing the words "Original" and "New" kama inafaa):

  • Original.xslt
  • New.xslt
  • Awali Params.xml
  • Mpya Params.xml

Katika kesi yangu, inaonekana kama hii:

picha

Modify the web part and copy the params and XSL to the "Original" toleo katika Visual Studio.

Lengo hapa ni kusababisha XSL wa kubadilisha matokeo ya sisi kupata nyuma kutoka swala DVWP katika HTML kuwa mithili kama graph.

Hadi mwisho huu, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (Kuwa wazi, zifuatazo ni tu mfano; 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:

Sampuli ya Grafu ya Baa

Sambamba HTML:

<html>
<mwili>
<kituo cha>
<meza width = 80%>
<tr><td><kituo cha>Horizontal Bar Grafu</td></tr>
<tr>
<td align="center">
<table border="1" width = 80%>
<tr>
<td width = 10%>Kufungua</td>
<td><meza cellpadding ="0" cellspacing ="0" mpaka = 0 upana = 50%><tr Bgcolor = nyekundu><td>&nbsp;</td></tr></meza></td>
</tr>
<tr>
<td width = 10%>Kufungwa</td>
<td><meza cellpadding ="0" cellspacing ="0" mpaka = 0 width = 25%><tr Bgcolor = nyekundu><td>&nbsp;</td></tr></meza></td>
</tr>
<tr>
<td width = 10%>Umesitishwa</td>
<td><meza cellpadding ="0" cellspacing ="0" mpaka = 0 width = 25%><tr Bgcolor = nyekundu><td>&nbsp;</td></tr></meza></td>
</tr>
</meza>
</td>
</tr>
</meza>
</mwili>
</html>

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

kuchukua-mbali hapa ni hii: Katika mwisho, wote sisi ni kufanya ni kujenga HTML na safu na nguzo.

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

  • Nilianza kwa XSL default kwamba SharePoint Designer alinipa wakati mimi kwanza kuundwa DVWP.
  • Nilikuwa na uwezo wa kata hii ya chini kutoka SPD 657 mistari ya 166 lines.
  • Mimi si fujo karibu na faili vigezo XML (ambayo ni tofauti na XSL na wewe utakuwa kujua nini maana mimi wakati wewe kwenda kurekebisha DVWP yenyewe; kuna mbili files unaweza kurekebisha). Hata hivyo, ili kurahisisha hilo, 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. Kisha, remove my calls and insert your own calls to "ShowBar".
  • drill chini anafanya kazi kwa kujenga <href> kama hii: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. At first, Nilidhani napenda haja ya kuendana na muundo ngumu zaidi: 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.

Hapa ni:

<xsl:Lahamtindo toleo="1.0" kuwatenga-matokeo-viambishi awali="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:the="urn:schemas-Microsoft-com:ofisi" 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:ndani"
> <xsl:pato njia="html" Indent="hakuna" /> <xsl:decimal-format NaN="" /> <xsl:kuacha jina="ListUrlDir"></xsl:kuacha> <!-- Mimi haja hii kwa msaada wa drill-chini. --> <xsl:template mechi="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:__designer=http://schemas.microsoft.com/WebParts/v2/DataView/designer xmlns:ASP="http://schemas.microsoft.com/ASPNET/20"
> <xsl:variable jina="dvt_StyleName">Meza</xsl:variable> <xsl:variable jina="Safu" kuchagua="/dsQueryResponse / Safu / Row" /> <xsl:variable jina="dvt_RowCount" kuchagua="kuhesabu($Safu)" /> <xsl:variable jina="IsEmpty" kuchagua="$dvt_RowCount = 0" /> <xsl:variable jina="dvt_IsEmpty" kuchagua="$dvt_RowCount = 0" /> <xsl:kuchagua> <xsl:wakati mtihani="$dvt_IsEmpty"> Hakuna data kwa graph!<br/> </xsl:wakati> <xsl:vinginevyo> <!-- mambo ya kuvutia inaanza hapa. Hatuna budi kufafanua jozi ya vigezo kwa kila mstari katika graph: jumla ya idadi           . --> <xsl:variable jina="totalProposed" kuchagua="kuhesabu(/dsQueryResponse / Safu / Row[kurejesha-nafasi(@ Status) = 'Mapendekezo'])" /> <xsl:variable jina="percentProposed" kuchagua="$totalProposed div $ dvt_RowCount" /> <xsl:variable jina="totalInProcess" kuchagua="kuhesabu(/dsQueryResponse / Safu / Row[kurejesha-nafasi(@ Status) = 'Katika Mchakato'])" /> <xsl:variable jina="percentInProcess" kuchagua="$totalInProcess div $ dvt_RowCount" /> <xsl:variable jina="totalStalled" kuchagua="kuhesabu(/dsQueryResponse / Safu / Row[kurejesha-nafasi(@ Status) = 'Kushindikana'])" /> <xsl:variable jina="percentStalled" kuchagua="$totalStalled div $ dvt_RowCount" /> <!-- Sisi kufafanua meza yetu HTML hapa. Mimi kukopa kutoka kwa baadhi ya kiwango           . Nadhani itakuwa heshima           . --> <meza upana="100%" cellspacing="0" cellpadding="2" style="mpaka-kulia: 1 imara # C0C0C0; mpaka-chini: 1 imara # C0C0C0; mpaka-kushoto-style: imara; mpaka-kushoto-upana: 1; mpaka-juu-style: imara; mpaka-juu-upana: 1;"> <tr> <td align="kituo cha"> <meza mpaka="1" upana="100%"> <!-- Kwa kila hali ya kwamba tunataka graph, we call the "ShowBar" template. Sisi kupita: 1. studio kwa ajili ya safu. Hii ni kugeuza hyperlink. 2. asilimia (kutofautiana kutoka juu). 3. halisi shamba jina la kanuni kutoka orodha ya msingi. Hii                      . 4. Shamba thamani kuendana kwa #3. 5. Jumla ya vitu ya kanuni hii hali ya (si jumla kuu ya yote                      ). Hutoa <tr></tr> na usawa bar graph line. Sisi wito huu template kwa kanuni ya kila hali tunataka kuona. --> <xsl:wito-template jina="ShowBar"> <xsl:na-param jina="BarDisplayLabel" kuchagua="'Mapendekezo'"/> <xsl:na-param jina="BarPercent" kuchagua="$percentProposed"/> <xsl:na-param jina="QueryFilterFieldName" kuchagua="'Hali'"/> <xsl:na-param jina="QueryFilterFieldValue" kuchagua="'Mapendekezo'"/> <xsl:na-param jina="TotalItems" kuchagua="$totalProposed"></xsl:na-param> </xsl:wito-template> <xsl:wito-template jina="ShowBar"> <xsl:na-param jina="BarDisplayLabel" kuchagua="'Kushindikana'"/> <xsl:na-param jina="BarPercent" kuchagua="$percentStalled"/> <xsl:na-param jina="QueryFilterFieldName" kuchagua="'Hali'"/> <xsl:na-param jina="QueryFilterFieldValue" kuchagua="'Kushindikana'"/> <xsl:na-param jina="TotalItems" kuchagua="$totalStalled"></xsl:na-param> </xsl:wito-template> <xsl:wito-template jina="ShowBar"> <xsl:na-param jina="BarDisplayLabel" kuchagua="'Katika Mchakato'"/> <xsl:na-param jina="BarPercent" kuchagua="$percentInProcess"/> <xsl:na-param jina="QueryFilterFieldName" kuchagua="'Hali'"/> <xsl:na-param jina="QueryFilterFieldValue" kuchagua="'Katika Mchakato'"/> <xsl:na-param jina="TotalItems" kuchagua="$totalInProcess"></xsl:na-param> </xsl:wito-template> </meza> </td> </tr> </meza> </xsl:vinginevyo> </xsl:kuchagua> </xsl:template> <!-- Template hii anafanya kazi ya kuonyesha mistari ya mtu binafsi katika graph bar. Pengine utasikia kufanya zaidi ya tweaking yako hapa. --> <xsl:template jina="ShowBar"> <xsl:kuacha jina="BarDisplayLabel" /> <!-- studio ya kuonyesha --> <xsl:kuacha jina="BarPercent"/> <!-- Asilimia ya jumla ya. --> <xsl:kuacha jina="QueryFilterFieldName"/> <!-- Kutumika Rukia swala & kuchuja --> <xsl:kuacha jina="QueryFilterFieldValue"/> <!-- Kutumika Rukia swala & kuchuja --> <xsl:kuacha jina="TotalItems" /> <!-- taarifa ya hesabu ya hii barlabel --> <tr> <!-- studio bar yenyewe. --> <td darasani="ms-formbody" upana="30%"> <!-- Hii seti ya pili ya kauli hujenga kamba swala ambayo inaruhusu           . Sisi kufanya matumizi ya mambo machache hapa: 1. Tunaweza kupita FilterField1 na FilterValue1 kwenye orodha kuweza kuchuja kwenye safu. 2. SharePoint ni kupita parameter muhimu kwetu, ListUrlDir that points to the underlying list against which this DVWP is "running". Si XSL furaha? --> <xsl:Nakala Disable-pato-kukimbia="ndiyo"> <![CDATA[<href ="]]></xsl:Nakala> <xsl:thamani ya kuchagua="$ListUrlDir"/> <xsl:Nakala Disable-pato-kukimbia="ndiyo"><![CDATA[?FilterField1 =]]></xsl:Nakala> <xsl:thamani ya kuchagua="$QueryFilterFieldName"/> <xsl:Nakala Disable-pato-kukimbia="ndiyo"><![CDATA[&FilterValue1 =]]></xsl:Nakala> <xsl:thamani ya kuchagua="$QueryFilterFieldValue"/> <xsl:Nakala Disable-pato-kukimbia="ndiyo"><![CDATA[">]]></xsl:Nakala> <xsl:thamani ya kuchagua="$BarDisplayLabel"/> <xsl:Nakala Disable-pato-kukimbia="ndiyo"><![CDATA[</a>]]></xsl:Nakala> <!-- kidogo ijayo inaonyesha idadi ya baadhi katika muundo: "(taarifa / % ya jumla ya)" --> (<xsl:thamani ya kuchagua="$TotalItems"/> / <!-- Hii inajenga nzuri asilimia studio kwa ajili yetu. Shukrani, Microsoft! --> <xsl:wito-template jina="percentformat"> <xsl:na-param jina="asilimia" kuchagua="$BarPercent"/> </xsl:wito-template>) </td> <!-- Hatimaye, emit <td> tag kwa bar yenyewe.--> <td> <meza cellpadding="0" cellspacing="0" mpaka="0" upana="{pande zote($BarPercent * 100)+1}%"> <tr Bgcolor="nyekundu"> <xsl:Nakala Disable-pato-kukimbia="ndiyo"><![CDATA[&nbsp;]]></xsl:Nakala> </tr> </meza> </td> </tr> </xsl:template> <!-- Hii ni kuchukuliwa moja kwa moja kutoka kwa baadhi XSL nimeona katika template MS. --> <xsl:template jina="percentformat"> <xsl:kuacha jina="asilimia"/> <xsl:kuchagua> <xsl:wakati mtihani="format-idadi($asilimia, '#, # # 0%;-#,##0%')= 'NaN'">0%</xsl:wakati> <xsl:vinginevyo> <xsl:thamani ya kuchagua="format-idadi($asilimia, '#, # # 0%;-#,##0%')" /> </xsl:vinginevyo> </xsl:kuchagua> </xsl:template> </xsl:Lahamtindo>

Matokeo:

XSL kutoka juu inazalisha hii graph:

picha

Kuchimba chini kwa data ya msingi kwa kubonyeza kanuni hali ya:

picha

Kuhitimisha Mawazo:

Hii inaweza kuwa jumla?

I love hii dhana graphing, 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, tafadhali kufanya kumbuka katika maoni au email yangu.

Wima Grafu:

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, tafadhali nijulishe na nitaunganisha kwa furaha blogi yako 🙂

Nadhani kuwa changamoto na graph wima ni kwamba maandiko kwa graph ni vigumu zaidi ya kusimamia, lakini kwa hakika si vigumu.

Shamba la Gotcha ya:

Kuna angalau vitu viwili kwa kuangalia nje kwa pamoja na majina yako shamba.

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

        <xsl:variable jina="totalProposed" 
kuchagua="kuhesabu(/dsQueryResponse / Safu / Row[kurejesha-nafasi(@ Status) = 'Mapendekezo'])" />

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

   <xsl:variable jina="totalProposed" 
kuchagua="kuhesabu(/dsQueryResponse / Safu / Row[kurejesha-nafasi(@ Status_x0020_Code) = 'Mapendekezo'])" />

Pili, na mimi nina fuzzy kidogo juu ya hili, but you also need to be on the alert for field name changes. If you name your field "Status Code" na kisha baadaye, 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" viungo inaweza kusaidia kutambua na kurekebisha aina hii ya tatizo.

Kuhusu Alama ya kwamba:

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. Kwa mfano, if the percentage of "stalled" Aliamuru ni > 10% kisha kuonyesha kuwa nyekundu, otherwise show it in black. Kutumia <xsl:kuchagua> kukamilisha hili.

Rasilimali nyingine:

Furaha kubadilisha!

<mwisho />

Kujiunga na blog yangu!

Sasa Takwimu Via Orodha OM Desturi (au, Lakini nyingine OM Takwimu Displayor [kama YACC, lakini tofauti])

Leo, 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."

safu katika swali inaweza kuundwa, ilifutwa na re-umba katika mazingira ya mwingine, so I knew it wasn’t a reserved name. Hata hivyo, 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, alikuwa tovuti yangu kila nguzo kubeba katika orodha ya desturi na kambi, sorting and so forth. I found my answer five minutes later.

Kama na wakati mimi mafanikio kuchukua juu ya dunia, I think I will decree that all SharePoint tools providers must seriously consider surfacing their object model data in a custom list. That way, Nina uwezo kutafuta njia yoyote nataka (unakabiliwa, bila shaka, kwa kiwango SharePoint makala).