Arkivji tal-Kategorija: SharePoint Iżvilupp

Beware Bidliet Breaking għall ItemStyle.xsl

I kien qed jaħdem mal ItemStyle.xsl biex jippersonalizzaw l-ħarsa ta 'kontenut Web Mistoqsija Parti u d-dritt dwar il-ħin ikla, 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, ndunat dan il-messaġġ li jidher fil-mazz ta 'postijiet:

Kapaċi li juru din it-Taqsima tal-Web. Biex troubleshoot l-problema, tiftaħ din il-paġna tal-Web fil-Windows Servizzi kompatibbli SharePoint HTML editur bħal Microsoft Office SharePoint Designer. Jekk il-problema tippersisti, ikkuntattja l-amministratur tiegħek Web server.

I ħtija tal-klijent (ma rrealizza li għadu li kien tort tiegħi f'dan il-punt) but eventually noticed that visual studio intellisense was warning me that I had malformed XSL. I corrected it and everything started working.

Ikunu attenti meta darned jaħdmu ma ItemStyle.xsl (u kwalunkwe mill-fajls XSL globali) — jkissruhom taffettwa artifacts ħafna fil-ġbir sit.

<aħħari />

Uri Mistoqsija Parti kontenut Riżultati Web fil-Grid / Tabella

Ħarsa ġenerali u Objettiv

Barra mill-kaxxa, MOSS’ Parti kontenut Web Mistoqsija (CQWP) juri r-riżultati tagħha f'format lista, similar to search results. It is also possible to display the results in a grid format (I.E. F'format ta 'tabella HTML). Grid formats are better in some circumstances. I describe how to achieve that effect in this article.

Xenarju Business

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, such as title, budget, expected completion date, remaining budget and other summary type fields. By "singleton" I mean a custom SharePoint list guaranteed to contain only one item. Simplistically, jidher qisu dan:

immaġni

The technical approach is much the same as described hawn (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:

immaġni

HTML like this generates that result:

<html>
 <korp>
 <ċentru>
 <tabella fruntiera=1>

<!-- Labels -->
 <tr bgcolor=blue>
 <td><font color=white><b>Project Name</b></font></td>
 <td jallinjaw=right><font color=white><b>Complete Date</b></font></td>
 <td jallinjaw=right><font color=white><b>Budget</b></font></td>
 <td jallinjaw=right><font color=white><b>Actual Expense</b></font></td>
 <td><font color=white><b>Overall Status</b></font></td>
 </tr>

<tr>
 <td>Re-wire computer room.</td>
 <td jallinjaw=right>02/01/08</td>
 <td jallinjaw=right>22,500.00</td>
 <td jallinjaw=right>19,000.00</td>
 <td>In Progress</td>
 </tr>

<tr>
 <td>Provision servers for SQL Upgrade</td>
 <td jallinjaw=right>04/01/08</td>
 <td jallinjaw=right>7,500.00</td>
 <td jallinjaw=right>0.00</td>
 <td>Planned</td>
 </tr>

</tabella>
 </ċentru>
 </korp>
</html>

Approach

Follow these steps to create the grid:

  1. Identify the components of the grid (rows/columns).
  2. Define and create necessary site columns.
  3. Create sub sites for the projects and singleton lists.
  4. Add the CQWP to a web page and configure it to search for your lists.
  5. Modify the CQWP’s XML to gather up the additional columns.
  6. Modify the XSL to generate a table.

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 hawn (http://msdn2.microsoft.com/en-us/library/bb897399.aspx) and Heather Solomon’s blog hawn (http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx).

Nuts And Bolts

Begin and implement steps one through five as per the MSDN documentation and Heather Solomon’s article.

F'dan il-punt, you’ve added your CQWP to the page and you have your <CommonViewFields> configured as necessary.

Following the usual steps, I get these intermediate results:

1. Oħloq tip kontenut, a templatized custom list for that content type and two sites. Here is the content type:

immaġni

Here is the site structure:

immaġni

2. Add the CQWP after creating my project subsites and singleton project summary lists:

immaġni

3. Add all the additional information I want via the <CommonViewFields>:

        <proprjetà isem="CommonViewFields" tip="string">Project_x0020_Name;Project_x0020_Expenses;Project_x0020_Status;Project_x0020_Start_x0020_Date;Project_x0020_End_x0020_Date;Project_x0020_Budget</proprjetà>

Note that I had to keep all the property fields on one line or it would not work (CQWP would tell me that the query returned no items).

4. F'dan il-punt, 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 to create a customized / unghosted version of ItemStyle.xsl. I follow Heather’s advice, up through step 11 and get these intermediate results:

4.1: Name my XSL template as follows:

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

I also slightly modify her suggested <XSL:għal-kull …> by adding a <br /> tag to provide a cleaner listing:

    <XSL:għal-kull tagħżel="@*">
      P:<XSL:il-valur tal- tagħżel="isem()" /><br/>
    </XSL:għal-kull>

4.2: I modify the web part, go to appearance and select my "Grid" stil:

immaġni

Apply the change and here is the result:

immaġni

We can see from the above that the fields we want (Project name, expense, status, eċċ) 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. Per eżempju, we reference Project Status as "Project_x005F_x0020_Name".

F'dan il-punt, we depart from Heather’s blog and from the shoulders of these giants, I add my own little bit.

ContentQueryMain.xsl

NOTA: When making changes to both ContentQueryMain.xsl as well as ItemStyle.xsl, you need to check those files back in before you see the effect of your changes.

For grid-making purposes, 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 <tabella> tag before emitting the first row of data and the closing <tabella> tag after emitting the last row. To accomplish this, ContentQueryMain.xsl is modified to pass two parameters to our "grid" template in ItemStyle.xsl, "last row" and "current row". ItemStyle.xsl uses these to conditionally emit the necessary tags.

Using Heather Solomon’s technique, we locate ContentQueryMain.xsl. It is located in the same place as ItemStyle.xsl. This screen shot should help:

immaġni

We need to make the following changes:

  • Modify an xsl template, "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 <tabella> tags.
  • Modify another bit of ContentQueryMain.xsl that calls the "CallItemTemplate" to pass it a "LastRow" parameter so that LastRow may be passed on to our Grid template.

Locate the template named "OuterTemplate.CallItemTemplate" identified by the string:

  <XSL:template isem="OuterTemplate.CallItemTemplate">

Replace the whole template as follows:

  <XSL:template isem="OuterTemplate.CallItemTemplate">
    <XSL:param isem="CurPosition" />

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

    <XSL:jagħżlu>
      <XSL:Meta test="@Style='NewsRollUpItem'">
        <XSL:apply-templates tagħżel="." mode="itemstyle">
          <XSL:ma 'param isem="EditMode" tagħżel="$cbq_iseditmode" />
        </XSL:apply-templates>
      </XSL:Meta>
      <XSL:Meta test="@Style='NewsBigItem'">
        <XSL:apply-templates tagħżel="." mode="itemstyle">
          <XSL:ma 'param isem="CurPos" tagħżel="$CurPosition" />
        </XSL:apply-templates>
      </XSL:Meta>
      <XSL:Meta test="@Style='NewsCategoryItem'">
        <XSL:apply-templates tagħżel="." mode="itemstyle">
          <XSL:ma 'param isem="CurPos" tagħżel="$CurPosition" />
        </XSL:apply-templates>
      </XSL:Meta>

      <!--
              Pass current position and lastrow to the Grid itemstyle.xsl template.
              ItemStyle.xsl will use that to emit the open and closing <tabella> tags.
      -->
      <XSL:Meta test="@Style='Grid'">
        <XSL:apply-templates tagħżel="." mode="itemstyle">
          <XSL:ma 'param isem="CurPos" tagħżel="$CurPosition" />
          <XSL:ma 'param isem="Last" tagħżel="$LastRow" />
        </XSL:apply-templates>
      </XSL:Meta>

      <XSL:inkella>
        <XSL:apply-templates tagħżel="." mode="itemstyle">
        </XSL:apply-templates>
      </XSL:inkella>
    </XSL:jagħżlu>
  </XSL:template>

The comments describe the purpose of the changes.

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

<XSL:template isem="OuterTemplate.Body">

Scroll through the instructions in OuterTemplate.Body and insert the LastRow parameter as follows (shown as a comment in italics):

<XSL:call-template isem="OuterTemplate.CallItemTemplate">
  <XSL:ma 'param isem="CurPosition" tagħżel="$CurPosition" />
  <!-- Insert the LastRow parameter. -->
  <XSL:ma 'param isem="LastRow" tagħżel="$LastRow"/>
</XSL:call-template>

After all of this, we finally have things set up properly so that our ItemStyle.xsl can emit <tabella> tags at the right place.

ItemStyle.Xsl

NOTA: Għal darb'oħra, check in ItemStyle.xsl after making any changes so that you see the effect of those changes.

We have two tasks here:

  • 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. (You can tell that I have a tenuous handle on XSL).

Ewwel, near the top of ItemStyle.xsl, add this line:

  <!-- Some mumbo jumbo that enables us to display U.S. currency. -->
  <XSL:dećimali-format isem="staff" digit="D" />

  <XSL:template isem="Default" jaqblu="*" mode="itemstyle">

Note that I added it directly before the <XSL:template name="Default" …> definition.

Li jmiss, go back to our Grid template. Replace the entire Grid template with the code below. It is thoroughly commented, but don’t hesitate to email me or leave comments on my blog if you have questions.

  <XSL:template isem="Grid" jaqblu="Row[@Style='Grid']" mode="itemstyle">

    <!--
      ContentMain.xsl passes CurPos and Last.
      We use these to conditionally emit the open and closing <tabella> tags.
    -->
    <XSL:param isem="CurPos" />
    <XSL:param isem="Last" />

    <!-- The following variables are unmodified from the standard ItemStyle.xsl -->
    <XSL:varjabbli isem="SafeImageUrl">
      <XSL:call-template isem="OuterTemplate.GetSafeStaticUrl">
        <XSL:ma 'param isem="UrlColumnName" tagħżel="'ImageUrl'"/>
      </XSL:call-template>
    </XSL:varjabbli>
    <XSL:varjabbli isem="SafeLinkUrl">
      <XSL:call-template isem="OuterTemplate.GetSafeLink">
        <XSL:ma 'param isem="UrlColumnName" tagħżel="'LinkUrl'"/>
      </XSL:call-template>
    </XSL:varjabbli>
    <XSL:varjabbli isem="DisplayTitle">
      <XSL:call-template isem="OuterTemplate.GetTitle">
        <XSL:ma 'param isem="Titolu" tagħżel="@Title"/>
        <XSL:ma 'param isem="UrlColumnName" tagħżel="'LinkUrl'"/>
      </XSL:call-template>
    </XSL:varjabbli>
    <XSL:varjabbli isem="LinkTarget">
      <XSL:jekk test="@OpenInNewWindow = 'True'" >_blank</XSL:jekk>
    </XSL:varjabbli>

    <!--
      Here we define a variable, "tableStart".  This contains the HTML
      that we use to define the opening of the table as well as the column
      labels.  Note that if CurPos = 1, it includes the HTML in a CDATA tag.
      Otherwise, it will be empty.

      The value of tableStart is emited every time ItemStyle is called via
      ContentQueryMain.xsl.
    -->
    <XSL:varjabbli isem="tableStart">
      <XSL:jekk test="$CurPos = 1">
        <![CDATA[
        <table border=1>
          <tr bgcolor="blue">
            <td><font color="white"><b>Project Name</b></font></td>
            <td align="right"><font color="white"><b>Complete Date</b></font></td>
            <td align="right"><font color="white"><b>Budget</b></font></td>
            <td align="right"><font color="white"><b>Actual Expense</b></font></td>
            <td><font color="white"><b>Overall Status</b></font></td>
          </tr>
        ]]>
      </XSL:jekk>
    </XSL:varjabbli>

    <!--
      Another variable, tableEnd simply defines the closing table tag.

      As with tableStart, it's always emited.  This is why its value is
      assigned conditionally based upon whether we've been passed the last
      row by ContentQueryMain.xsl.
    -->
    <XSL:varjabbli isem="tableEnd">
      <XSL:jekk test="$CurPos = $Last">
        <![CDATA[ </tabella> ]]>
      </XSL:jekk>
    </XSL:varjabbli>

    <!--
      Always emit the contents of tableStart.  If this is not the first
      row passed to us by ContentQueryMain.xsl, then we know its value
      will be blank.

      Disable output escaping because when tableStart it not blank, it
      includes actual HTML that we want to be rendered by the browser.  If
      we don't tell the XSL parser to disable output escaping, it will generate
      stuff like "&lt;tabella&gt;" instead of "<tabella>".
    -->
    <XSL:il-valur tal- tagħżel="$tableStart" jiskonnettja-output-ħarba="iva"/>


    <tr>
      <!--
      P:Project_x005F_x0020_Name
      P:Project_x005F_x0020_End_x005F_x0020_Date
      P:Project_x005F_x0020_Budget
      P:Project_x005F_x0020_Expenses
      P:Project_x005F_x0020_Status
      -->
      <td>
        <XSL:il-valur tal- tagħżel="@Project_x005F_x0020_Name"/>
      </td>

      <td jallinjaw="dritt">
        <XSL:il-valur tal- tagħżel="@Project_x005F_x0020_End_x005F_x0020_Date"/>
      </td>

      <td jallinjaw="dritt">
        <XSL:call-template isem="formatcurrency">
          <XSL:ma 'param isem="valur" 
tagħżel="@Project_x005F_x0020_Budget"></XSL:ma 'param> </XSL:call-template> </td> <td jallinjaw="dritt"> <XSL:call-template isem="formatcurrency"> <XSL:ma 'param isem="valur" tagħżel="@Project_x005F_x0020_Expenses">
</XSL:ma 'param> </XSL:call-template> </td> <td> <XSL:il-valur tal- tagħżel="@Project_x005F_x0020_Status"/> </td> <!-- All of the following is commented out to clarify things. Madankollu, bring it back and stuff it into a <td> to see its effect. --> <!-- <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:jekk> <div class="link-item"> <XSL:call-template
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> <!-- Emit the closing table tag. If we are not on the last row, this will be blank. --> <XSL:il-valur tal- tagħżel="$tableEnd" jiskonnettja-output-ħarba="iva"/> </XSL:template> <XSL:template isem="formatcurrency"> <XSL:param isem="valur" tagħżel="0" /> <XSL:il-valur tal- tagħżel="-Numru format($valur, "$DDD,DDD,DDD.DD", "staff")" /> </XSL:template>

Standard WSS / MOSS Screens Dħul ta 'Data ma jsostnux Cascading Drop-downs (jew oħrajn intra-komunikazzjoni mill-)

UPDATE (04/2008): Din l-entrata blog kbir juri approċċ ibbażat javascript tajba biex din il-problema: http://webborg.blogspot.com/2008/04/add-functions-and-events-to-sharepoint.html

AĠĠORNAMENT II: (04/2008): Din l-entrata blog tidher promettenti kif ukoll: http://www.cleverworkarounds.com/2008/03/13/free-mosswss-2007-web-part-hide-controls-via-javascript/

Diversi drabi fil-ġimgħa, jekk mhux kuljum, forum users describe a requirement that would normally be met via cascading drop-downs. Per eżempju, Għandi żewġ kontrolli drop-down:

  • Lista ta 'U.S. istati
  • Lista ta 'U.S. bliet.

Bħala fornituri UI responsabbli, irridu li jopera bħal dan:

  • Paul jagħżel 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 jagħżel belt mill-lista iffiltrat.

There is no out-of-the-box support for this feature. Fil-fatt, 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.

L-għan reali ta 'dan l-artikolu li biex jiddeskrivi soluzzjonijiet possibbli u dawn huma l-għażliet kif naf minnhom:

  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. F'dan il-każ, inti normalment tipprova tuża kolonna kkalkulata, iżda xi drabi, 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, ikunu konxji tal-kwistjoni indirizzata minn dan l-artikolu (http://paulgalvin.spaces.live.com/blog/cns!CC1EDB3DAA9B8AA!405.entry).
  3. Handlers Avveniment: Bħall 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 (u l-mudell oġġett sħiħ) u tista 'tagħmel kwalunkwe kalkolu meħtieġ.
  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 ASP.NET funzjoni dħul tiegħek data (bħala paġna web stand-alone jew bħala parti web) u l-użu li minflok.

Jekk xi ħadd jaf l-oħra u / jew aħjar għażliet, jekk jogħġbok post kumment u jien ser taġġorna l-korp ta 'din il-kariga.

<aħħari />

Oħloq Grafiċi Bar fl SharePoint

Ħarsa ġenerali:

(UPDATE 12/04/07: Miżjud riżors ieħor interessanti fl-aħħar jgħaqqdu għal ieħor blog li tindirizza din permezz ta 'parti web interessanti ħafna)

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.

L-approċċ ġenerali hija kif ġej:

  1. Tinħoloq lista jew il-librerija dokument li jkun fih l-informazzjoni li inti tixtieq li graff.
  2. Poġġi l-librerija dokument ieħor assoċjat, / lista tad-dwana fuq il-paġna u jaqilbu għal parti data web ħsieb (DVWP).
  3. Tibdel XSL l DVWP li tiġġenera HTML li turi bħala graff.

Xenarju Business / Setup:

I ħolqu lista custom mal-Titolu kolonna standard u l-kolonna addizzjonali waħda, "Status". This models (ħafna simplistikament) an "Authorization For Expense" xenarju fejn it-titolu jirrappreżenta l-proġett u l-Istatus ta 'valur mil-lista ta':

  • Propost
  • Fil Proċess
  • Waqfu

L-għan huwa li jipproduċu graff interattiv bar orizzontali li turi dawn il-kodiċijiet istat.

Għandi popolati il-lista u jidher qisu dan:

immaġni

Oħloq Data View Web Parti:

Oħloq il-DVWP billi żżid il-lista tad-dwana għal paġna (Paġna sit fil-każ tiegħi) u segwi l-istruzzjonijiet hawn (http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!395.entry).

Minbarra li sempliċiment toħloq l-DVWP, we also need to set the paging property to show all available rows. Għalija, dan jistenna xi ħaġa bħal din:

immaġni

F'dan il-punt, 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.

Tibdel il XSLT:

Issa huwa żmien biex jimmodifika l-XSLT.

I always use visual studio for this. (Ara hawn għal nota importanti dwar IntelliSense li ser jgħinek ħafna).

I joħolqu proġett vojta żid erba fajls ġodda (replacing the words "Original" and "New" kif xieraq):

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

Fil-każ tiegħi, jidher qisu dan:

immaġni

Modify the web part and copy the params and XSL to the "Original" verżjoni fis Visual Studio.

L-għan hawnhekk huwa li jikkawża l XSL li tittrasforma r-riżultati nikbru lura mill-mistoqsija DVWP fis HTML li jirrendi bħala graff.

Biex dan il-għan, it helps to first consider what the HTML should look like before we get confused by the insanity that is known as "XSL". (Biex ikunu ċari, li ġej huwa sempliċement eżempju; 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

HTML Korrispondenti:

<html>
<korp>
<ċentru>
<wisa tabella = 80%>
<tr><td><ċentru>Grafika Bar orizzontali</td></tr>
<tr>
<td align="center">
<table border="1" wisa '= 80%>
<tr>
<wisa td = 10%>Open</td>
<td><tabella cellpadding ="0" cellspacing ="0" fruntiera = 0 wisa '= 50%><tr bgcolor = aħmar><td>&nbsp;</td></tr></tabella></td>
</tr>
<tr>
<wisa td = 10%>Magħluq</td>
<td><tabella cellpadding ="0" cellspacing ="0" fruntiera = 0 wisa '= 25%><tr bgcolor = aħmar><td>&nbsp;</td></tr></tabella></td>
</tr>
<tr>
<wisa td = 10%>Waqfu</td>
<td><tabella cellpadding ="0" cellspacing ="0" fruntiera = 0 wisa '= 25%><tr bgcolor = aħmar><td>&nbsp;</td></tr></tabella></td>
</tr>
</tabella>
</td>
</tr>
</tabella>
</korp>
</html>

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

Il-take-away hawnhekk hija din: Fl-aħħar, kollha qed nagħmlu qed toħloq HTML ma ringieli u kolonni.

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 beda bil-default XSL li SharePoint Designer tatni meta I ewwel ħolqu l-DVWP.
  • I kien kapaċi li tnaqqas din stabbiliti minn dak tal-SPD 657 linji għal 166 lines.
  • I ma mess madwar il-fajl XML parametri (li hija separata mill-XSL u tkun taf taf dak li jfisser meta inti tmur biex jimmodifikaw il-DVWP innifsu; hemm żewġ fajls li inti tista 'timmodifika). Madankollu, sabiex tkun issimplifikata, 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. Imbagħad, remove my calls and insert your own calls to "ShowBar".
  • Il-drill isfel jaħdem billi toħloq <a href> bħal dan: http://server/List?FilterField1=fieldname&FilterValue1=actualFilterValue. This technique may be of value in other contexts. Fl-ewwel, Ħsibt I bżonn biex jikkonformaw ma 'format aktar kumplessi: 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.

Hawnhekk huwa:

<XSL:stylesheet Verżjoni="1.0" jeskludu-riżultat-prefissi="rs z o i ddwrt dt msxsl" 
xmlns:msxsl="urn:schemos-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:schemos-microsoft-com:uffiċċju" xmlns:i="UUID:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="UUID:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemos-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns:ddwrt2="urn:Frontpage:intern"
> <XSL:output metodu="html" inċiż="ebda" /> <XSL:dećimali-format NaN="" /> <XSL:param isem="ListUrlDir"></XSL:param> <!-- I bżonn dan li tappoġġja drill-down. --> <XSL:template jaqblu="/" xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:__designer=http://schemas.microsoft.com/WebParts/v2/DataView/designer xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
> <XSL:varjabbli isem="dvt_StyleName">Tabella</XSL:varjabbli> <XSL:varjabbli isem="Ringieli" tagħżel="/dsQueryResponse / Ringieli / Ringiela" /> <XSL:varjabbli isem="dvt_RowCount" tagħżel="joqgħod($Ringieli)" /> <XSL:varjabbli isem="IsEmpty" tagħżel="$dvt_RowCount = 0" /> <XSL:varjabbli isem="dvt_IsEmpty" tagħżel="$dvt_RowCount = 0" /> <XSL:jagħżlu> <XSL:Meta test="$dvt_IsEmpty"> M'hemm l-ebda data lill-graff!<br/> </XSL:Meta> <XSL:inkella> <!-- L-għalf interessanti jibda hawn. Għandna bżonn li jiddefinixxu par ta 'varjabbli għal kull ringiela fil-graff: numru totali           . --> <XSL:varjabbli isem="totalProposed" tagħżel="joqgħod(/dsQueryResponse / Ringieli / Ringiela[jinnormalizzaw l-ispazju(@ Status) = "Proposti"])" /> <XSL:varjabbli isem="percentProposed" tagħżel="$totalProposed div $ dvt_RowCount" /> <XSL:varjabbli isem="totalInProcess" tagħżel="joqgħod(/dsQueryResponse / Ringieli / Ringiela[jinnormalizzaw l-ispazju(@ Status) = "Fil Proċess"])" /> <XSL:varjabbli isem="percentInProcess" tagħżel="$totalInProcess div $ dvt_RowCount" /> <XSL:varjabbli isem="totalStalled" tagħżel="joqgħod(/dsQueryResponse / Ringieli / Ringiela[jinnormalizzaw l-ispazju(@ Status) = "Waqaf"])" /> <XSL:varjabbli isem="percentStalled" tagħżel="$div totalStalled $ dvt_RowCount" /> <!-- Aħna jiddefinixxu tabella HTML tagħna hawn. Jien self minn xi standard           . Naħseb li se unur           . --> <tabella wisa="100%" cellspacing="0" cellpadding="2" stil="-dritt transkonfinali: 1 solidu # C0C0C0; fruntiera tal-qiegħ: 1 solidu # C0C0C0; -xellug stil fruntiera: solidu; -left-wisa fruntiera: 1; fruntiera-top-istil: solidu; -top-wisa fruntiera: 1;"> <tr> <td jallinjaw="ċentru"> <tabella fruntiera="1" wisa="100%"> <!-- Għal kull status li rridu graff, we call the "ShowBar" template. Aħna tgħaddiha: 1. A tikketta għar-ringiela. Dan huwa trasformat hyperlink. 2. Il-mija (varjabbli minn fuq). 3. L-isem medda attwali tal-kodiċi mil-lista sottostanti. Dan                      . 4. Valur Field mqabbla għal #3. 5. Oġġetti totali ta 'dan il-kodiċi status (mhux-total sħiħ ta 'kulħadd                      ). Hija temetti <tr></tr> u l-bar graff linja orizzontali. Aħna nsejħu dan il-mudell għal kull kodiċi status aħna tixtieq tara. --> <XSL:call-template isem="ShowBar"> <XSL:ma 'param isem="BarDisplayLabel" tagħżel=""Proposti""/> <XSL:ma 'param isem="BarPercent" tagħżel="$percentProposed"/> <XSL:ma 'param isem="QueryFilterFieldName" tagħżel=""Status""/> <XSL:ma 'param isem="QueryFilterFieldValue" tagħżel=""Proposti""/> <XSL:ma 'param isem="TotalItems" tagħżel="$totalProposed"></XSL:ma 'param> </XSL:call-template> <XSL:call-template isem="ShowBar"> <XSL:ma 'param isem="BarDisplayLabel" tagħżel=""Waqaf""/> <XSL:ma 'param isem="BarPercent" tagħżel="$percentStalled"/> <XSL:ma 'param isem="QueryFilterFieldName" tagħżel=""Status""/> <XSL:ma 'param isem="QueryFilterFieldValue" tagħżel=""Waqaf""/> <XSL:ma 'param isem="TotalItems" tagħżel="$totalStalled"></XSL:ma 'param> </XSL:call-template> <XSL:call-template isem="ShowBar"> <XSL:ma 'param isem="BarDisplayLabel" tagħżel=""Fil Proċess""/> <XSL:ma 'param isem="BarPercent" tagħżel="$percentInProcess"/> <XSL:ma 'param isem="QueryFilterFieldName" tagħżel=""Status""/> <XSL:ma 'param isem="QueryFilterFieldValue" tagħżel=""Fil Proċess""/> <XSL:ma 'param isem="TotalItems" tagħżel="$totalInProcess"></XSL:ma 'param> </XSL:call-template> </tabella> </td> </tr> </tabella> </XSL:inkella> </XSL:jagħżlu> </XSL:template> <!-- Dan template ma l-ħidma ta 'wiri linji individwali fil-graff bar. Int ser ikollok probabbilment jagħmlu ħafna mix tweaking tiegħek hawn. --> <XSL:template isem="ShowBar"> <XSL:param isem="BarDisplayLabel" /> <!-- tikketta li turi --> <XSL:param isem="BarPercent"/> <!-- Mija tat-total. --> <XSL:param isem="QueryFilterFieldName"/> <!-- Użati biex jaqbżu l-mistoqsija & filtru --> <XSL:param isem="QueryFilterFieldValue"/> <!-- Użati biex jaqbżu l-mistoqsija & filtru --> <XSL:param isem="TotalItems" /> <!-- għadd totali ta 'dan barlabel --> <tr> <!-- It-tikketta bar innifsu. --> <td klassi="ms-formbody" wisa="30%"> <!-- Dan is-sett li jmiss ta 'dikjarazzjonijiet jibni string query li tippermetti           . Nagħmlu użu ta 'ftit affarijiet hawn: 1. Nistgħu jgħaddu FilterField1 u FilterValue1 għal lista li filtru fuq kolonna. 2. SharePoint hija tgħaddi parametru ewlieni għalina, ListUrlDir that points to the underlying list against which this DVWP is "running". Mhuwiex XSL gost? --> <XSL:test jiskonnettja-output-ħarba="iva"> <![CDATA[<a href ="]]></XSL:test> <XSL:il-valur tal- tagħżel="$ListUrlDir"/> <XSL:test jiskonnettja-output-ħarba="iva"><![CDATA[?FilterField1 =]]></XSL:test> <XSL:il-valur tal- tagħżel="$QueryFilterFieldName"/> <XSL:test jiskonnettja-output-ħarba="iva"><![CDATA[&= FilterValue1]]></XSL:test> <XSL:il-valur tal- tagħżel="$QueryFilterFieldValue"/> <XSL:test jiskonnettja-output-ħarba="iva"><![CDATA[">]]></XSL:test> <XSL:il-valur tal- tagħżel="$BarDisplayLabel"/> <XSL:test jiskonnettja-output-ħarba="iva"><![CDATA[</a>]]></XSL:test> <!-- Il bit jmiss turi xi numri fil-format: "(total / % tat-total)" --> (<XSL:il-valur tal- tagħżel="$TotalItems"/> / <!-- Dan joħloq tikketta mija sbieħ għalina. Grazzi, Microsoft! --> <XSL:call-template isem="percentformat"> <XSL:ma 'param isem="mija" tagħżel="$BarPercent"/> </XSL:call-template>) </td> <!-- Fl-aħħarnett, jitfa ' <td> tag għall-bar innifsu.--> <td> <tabella cellpadding="0" cellspacing="0" fruntiera="0" wisa="{round($BarPercent * 100)+1}%"> <tr bgcolor="aħmar"> <XSL:test jiskonnettja-output-ħarba="iva"><![CDATA[&nbsp;]]></XSL:test> </tr> </tabella> </td> </tr> </XSL:template> <!-- Dan huwa meħud direttament minn xi XSL sibt fi SM template. --> <XSL:template isem="percentformat"> <XSL:param isem="mija"/> <XSL:jagħżlu> <XSL:Meta test="-Numru format($mija, "#, # # 0%;-#,##0%")= "NaN"">0%</XSL:Meta> <XSL:inkella> <XSL:il-valur tal- tagħżel="-Numru format($mija, "#, # # 0%;-#,##0%")" /> </XSL:inkella> </XSL:jagħżlu> </XSL:template> </XSL:stylesheet>

Ir-Riżultati:

Il XSL minn fuq jiġġenera dan il-graff:

immaġni

Drill stabbiliti għad-data sottostanti billi tikklikkja fuq l-status code:

immaġni

Ħsibijiet konklużivi:

Jista 'dan jiġi Ġeneralizzata?

I love dan il-kunċett 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, jekk jogħġbok ħu nota fil-kummenti jew email me.

Grafiċi vertikali:

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 🙂

Naħseb li l-isfida ma graff vertikali hija li t-tikketti għall-graff huma aktar diffiċli biex tamminstrahom, iżda ċertament mhux impossibbli.

Isem il-Qasam Gotcha tal:

Hemm mill-inqas żewġ affarijiet li għandek toqgħod attent għal mal-qasam ismijiet tiegħek.

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

        <XSL:varjabbli isem="totalProposed" 
tagħżel="joqgħod(/dsQueryResponse / Ringieli / Ringiela[jinnormalizzaw l-ispazju(@ Status) = "Proposti"])" />

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

   <XSL:varjabbli isem="totalProposed" 
tagħżel="joqgħod(/dsQueryResponse / Ringieli / Ringiela[jinnormalizzaw l-ispazju(@ Status_x0020_Code) = "Proposti"])" />

Tieni, u jien fuzzy ftit fuq dan, but you also need to be on the alert for field name changes. If you name your field "Status Code" u mbagħad aktar tard, 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" rabtiet jistgħu jgħinu dijanjosi u jikkoreġu dan it-tip ta 'problema.

Dwar dak Kulur:

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. Per eżempju, if the percentage of "stalled" Tal-AFE huwa > 10% mbagħad juru dan aħmar, otherwise show it in black. Użu <XSL:jagħżlu> biex dan jintlaħaq.

Riżorsi oħra:

Happy trasformazzjoni!

<aħħari />

Abbona għall-blog tiegħi!

Data Preżenti Via-Lista Custom OM (jew, Énième OM Data Displayor [bħal Yacc, imma differenti])

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

Il-kolonna in kwistjoni jistgħu jinħolqu, imħassra u maħluqa mill-ġdid fl-ambjent ieħor, so I knew it wasn’t a reserved name. Madankollu, 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, tal-kors, by standard sharepoint features).