How to show others columns

Dec 15, 2011 at 9:10 AM

Hi,

thanks a lot for this great code !

Can you tell me how to insert others column into the table ?

Regards,

Steve

Dec 16, 2011 at 9:39 PM

I am also wondering about how to show additional columns. thx

Mar 5, 2013 at 4:21 PM
Edited Mar 5, 2013 at 4:22 PM
Hi, guys.
If anybody still interests in this question, i've modified the source code to list other fields. It should be something like this: find the line with tag (it should be line 27):
 <xsl:template name="dvt_1">
Then modify everything from this line till the closing tag with your disired code. In my example:
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
    <xsl:variable name="Rows" select="/All_Results/Result"/>
    <table border="0" width="93%" cellpadding="4" cellspacing="2" id="ResultsTable" align="right">
      <tr valign="top">
        <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
          <th class="ms-vh" width="1%" nowrap="nowrap"></th>
        </xsl:if>
        <th class="ms-vh" nowrap="">

        </th>
        <th class="ms-vh" nowrap="" style="width: 257px" align="left">
          <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
            <xsl:with-param name="fieldname">TITLE</xsl:with-param>
            <xsl:with-param name="fieldtitle">SecondName</xsl:with-param>
            <xsl:with-param name="displayname">SecondName</xsl:with-param>
            <xsl:with-param name="sortable">1</xsl:with-param>
            <xsl:with-param name="fieldtype">Text</xsl:with-param>
          </xsl:call-template>
        </th>

        <th class="ms-vh" nowrap="" align="left">
          <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
            <xsl:with-param name="fieldname">firstname</xsl:with-param>
            <xsl:with-param name="fieldtitle">FirstName</xsl:with-param>
            <xsl:with-param name="displayname">FirstName</xsl:with-param>
            <xsl:with-param name="sortable">1</xsl:with-param>
            <xsl:with-param name="fieldtype">Text</xsl:with-param>
          </xsl:call-template>
        </th>
        <th class="ms-vh" nowrap="" align="left">
          MiddleName
        </th>
        <th class="ms-vh" nowrap="" align="left">
          JobTitle
        </th>
        <th class="ms-vh" nowrap="" align="left">
          PhoneNumber
        </th>
      </tr>
      <xsl:call-template name="dvt_1.body">
        <xsl:with-param name="Rows" select="$Rows"/>
      </xsl:call-template>
    </table>
This part describes the header of the resulting table. So that were just the titles of the fields you want to display. After that you should describe what fields to display in the table. So search for the tag (somewhere in the line 97):
<xsl:template name="dvt_1.rowview">
inside this tag you should add several descriptions - one for each of your fields:
      <td class="ms-vb">
        <xsl:value-of select="firstname"/>
      </td>

      <td class="ms-vb">
        <xsl:value-of select="middlename"/>
      </td>
      <td class="ms-vb">
        <xsl:value-of select="jobtitle"/>
      </td>
      <td class="ms-vb">
        <xsl:value-of select="workphone"/>
      </td>
and that all. Don't forget to add your fields to the "Fetched Properties". Also notice that it's better to use lowercase when describing field names.
Hope this could help to somebody.
I didn't find a way to display lookup-fields, so if someone knows how - please write it to this discussion.

Best regards, Andrew.
Apr 16, 2013 at 12:33 PM
Hi, AndrewForSP

your code is work fine ,but the column is not arranged properly am having four column

Title -- column empid is shown ,Name]
Name-- column age is shown
EmpID-- column address is shown
Address----
Age----

can you plz tell what modification we have to do in XSLT.This is my code.

<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:param name="dvt_adhocmode">sort</xsl:param>
<xsl:decimal-format NaN=""/>

<xsl:param name="FileName" />
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:param name="dvt_fieldsort" />
<xsl:param name="dvt_filterfield" />
<xsl:param name="dvt_sortdir">ascending</xsl:param>
<xsl:param name="dvt_sortfield" />
<xsl:param name="dvt_sorttype">text</xsl:param>
<xsl:param name="dvt_filterfields" />
<xsl:param name="dvt_partguid" />

<xsl:variable name="dvt_1_automode">0</xsl:variable>

<xsl:template match="/">
<xsl:call-template name="dvt_1"/>
<style type="text/css">
  .ms-alternatingstrong
  {
  background-color:#e3efff;
  }
</style>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/All_Results/Result"/>
<table border="0" width="97%" cellpadding="2" cellspacing="1" id="ResultsTable" align="left">
  <tr valign="top">
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
      <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
    <th class="ms-vh" nowrap="">

    </th>
    <th class="ms-vh" nowrap="" style="width: 257px" align="left">
      <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
        <xsl:with-param name="fieldname">TITLE</xsl:with-param>
        <xsl:with-param name="fieldtitle">Title</xsl:with-param>
        <xsl:with-param name="displayname">Title</xsl:with-param>
        <xsl:with-param name="sortable">1</xsl:with-param>
        <xsl:with-param name="fieldtype">Text</xsl:with-param>
      </xsl:call-template>
    </th>
<th class="ms-vh" nowrap="" align="left">
      <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
        <xsl:with-param name="fieldname">name</xsl:with-param>
        <xsl:with-param name="fieldtitle">Name</xsl:with-param>
        <xsl:with-param name="displayname">Name</xsl:with-param>
        <xsl:with-param name="sortable">1</xsl:with-param>
        <xsl:with-param name="fieldtype">Text</xsl:with-param>
      </xsl:call-template>
    </th>

<th class="ms-vh" nowrap="" align="left">
      <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
        <xsl:with-param name="fieldname">address</xsl:with-param>
        <xsl:with-param name="fieldtitle">Address</xsl:with-param>
        <xsl:with-param name="displayname">Address</xsl:with-param>
        <xsl:with-param name="sortable">1</xsl:with-param>
        <xsl:with-param name="fieldtype">Text</xsl:with-param>
      </xsl:call-template>
    </th>

<th class="ms-vh" nowrap="" align="left">
      <xsl:call-template name="dvt.headerfield" ddwrt:atomic="1">
        <xsl:with-param name="fieldname">age</xsl:with-param>
        <xsl:with-param name="fieldtitle">Age</xsl:with-param>
        <xsl:with-param name="displayname">Age</xsl:with-param>
        <xsl:with-param name="sortable">1</xsl:with-param>
        <xsl:with-param name="fieldtype">Text</xsl:with-param>
      </xsl:call-template>
    </th>




  </tr>
  <xsl:call-template name="dvt_1.body">
    <xsl:with-param name="Rows" select="$Rows"/>
  </xsl:call-template>
</table>

</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:for-each select="$Rows">
  <xsl:sort select="*[name() = $dvt_sortfield] | @*[name() = $dvt_sortfield] | text()[name(ancestor::*[1]) = $dvt_sortfield]" order="{$dvt_sortdir}" data-type="{$dvt_sorttype}" />
  <xsl:sort select="title" order="ascending" />
  <xsl:sort select="write" order="ascending" />
  <xsl:call-template name="dvt_1.rowview"/>



</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">

<td class="ms-vb">
    <xsl:value-of select="title"/>
  </td>

  <td class="ms-vb">
    <xsl:value-of select="name"/>
  </td>
  <td class="ms-vb">
    <xsl:value-of select="address"/>
  </td>
  <td class="ms-vb">
    <xsl:value-of select="age"/>
  </td>

<tr>
  <xsl:if test="position() mod 2 = 1">
    <xsl:attribute name="class">ms-alternatingstrong</xsl:attribute>
  </xsl:if>
  <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
    <td class="ms-vb" width="1%" nowrap="nowrap">
      <span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
    </td>
  </xsl:if>
  <td class="ms-vb">
    <img border="0" src="{imageurl/text()}" />
  </td>
  <td class="ms-vb" style="width: 257px">
    <a href="{url}">
      <xsl:value-of select="title" />
    </a>
  </td>
  <td class="ms-vb">

    <xsl:choose>
      <xsl:when test="string-length(hithighlightedsummary/text()) &lt; 80">
        <div>
          <xsl:value-of select="hithighlightedsummary/text()" />
        </div>
      </xsl:when>
      <xsl:otherwise>
        <div>
          <xsl:value-of select="substring(hithighlightedsummary/text(),1,75)" />
        </div>
        <a href="#" onclick="javascript:moreless(this,'{hithighlightedsummary}')">more&gt;&gt;</a>
      </xsl:otherwise>
    </xsl:choose>

    <script type="text/javascript">
      function moreless(abc,fullText)
      {
      if(abc.innerText == "more&gt;&gt;")
      {
      div = abc.parentNode.getElementsByTagName('div');
      div[0].innerText = fullText;
      abc.innerText = "&lt;&lt;less";
      }
      else if(abc.innerText == "&lt;&lt;less")
      {
      div = abc.parentNode.getElementsByTagName('div');
      div[0].innerText = fullText.substring(0,75);
      abc.innerText = "more&gt;&gt;";
      }

      }
    </script>
  </td>


  <td class="ms-vb">
    <xsl:value-of select="write"/>
  </td>
</tr>
</xsl:template>
<xsl:template name="dvt.headerfield">
<xsl:param name="fieldname" />
<xsl:param name="fieldtitle" />
<xsl:param name="displayname" />
<xsl:param name="sortable">1</xsl:param>
<xsl:param name="fieldtype">0</xsl:param>
<xsl:choose>
  <xsl:when test="($dvt_adhocmode = 'sort' or $dvt_fieldsort = '1')and $sortable='1'">
    <xsl:variable name="sortfield">
      <xsl:choose>
        <xsl:when test="substring($fieldname, string-length($fieldname) - 5) = '(text)'">
          <xsl:value-of select="substring($fieldname, 1, string-length($fieldname) - 6)" />
        </xsl:when>
        <xsl:when test="substring($fieldname, 1, 1) = '@'">
          <xsl:value-of select="substring($fieldname, 2)" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$fieldname" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="linkdir">
      <xsl:choose>
        <xsl:when test="$dvt_sortfield = $sortfield and $dvt_sortdir = 'ascending'">descending</xsl:when>
        <xsl:otherwise>ascending</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="sortText">
      <xsl:choose>
        <xsl:when test="$linkdir='descending'">&apos; + &apos;descending&apos; + &apos;</xsl:when>
        <xsl:otherwise>&apos; + &apos;ascending&apos; + &apos;</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="separator" select="' '" />
    <xsl:variable name="connector" select="';'" />
    <table CtxNum="1" cellspacing="0" class="ms-unselectedtitle" onmouseover="OnMouseOverAdHocFilter(this, '{concat($displayname,$separator,$fieldname, $separator,$fieldtype, $connector, 1033, $separator, $dvt_partguid)}')">
      <tr>
        <td width="100%" class="ms-vb" nowrap="">
          <a>
            <xsl:attribute name="href">
              javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_sortfield={',$sortfield,'};dvt_sortdir={',$sortText,'}'))" />;
            </xsl:attribute>
            <xsl:attribute name="onclick">
              javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_sortfield={',$sortfield,'};dvt_sortdir={',$sortText,'}'))" />;
            </xsl:attribute>
            <xsl:choose>
              <xsl:when test="$fieldtype = 'Attachments'">
                <xsl:value-of select="$fieldtitle" disable-output-escaping="yes" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$fieldtitle" />
              </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="$dvt_sortfield = $sortfield">
              <xsl:choose>
                <xsl:when test="$dvt_sortdir = 'ascending'">
                  <img border="0" alt="Ascending" src="{ddwrt:FieldSortImageUrl('Desc')}" />
                </xsl:when>
                <xsl:when test="$dvt_sortdir = 'descending'">
                  <img border="0" alt=