Xslt, JavaScript y WebService en Sharepoint – Demo 1

 No solo de WebParts vive el hombre – Parte 1

En el día de ayer, 06-12-2007 tuvimos la oportunidad de realizar un WebCast a la comunidad de desarrolladores de Sharepoint y le damos las gracias a Brandon Aday de Microsoft por la oportunidad que nos brindo.

En este WebCast presentamos una forma alternativa de realizar componentes para Sharepoint sin utilizar código de servidor.

Acá les dejamos el parte del código fuente de la primera presentación realizada, el mismo pertenece a un formulario con la WebPart DataFormWebPart y el código Xslt utilizado.

Código Fuente. 

<asp:Content id="Content1" runat="Server" contentplaceholderid="PlaceHolderMain">

<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle=’TRUE’ ViewFlag=’0′ Title=’Documentos’ __markuptype=’vsattributemarkup’ __WebPartId='{38D879FD-A279-4CA4-BF45-E4FE9AE57280}’ id=’g_2c3bed60_be55_4bef_90c7_5d9ba443f80a’ __AllowXSLTEditing=’true’ WebPart=’true’ Height=» Width=» showwithsampledata=’false’>

<DataSources>

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="Documentos1"><UpdateParameters><WebPartPages:dataformparameter PropertyName="ParameterValues" ParameterKey="ListID" DefaultValue="{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}" Name="ListID">

</WebPartPages:dataformparameter>

</UpdateParameters><DeleteParameters><WebPartPages:dataformparameter PropertyName="ParameterValues" ParameterKey="ListID" DefaultValue="{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}" Name="ListID">

</WebPartPages:dataformparameter>

</DeleteParameters><InsertParameters><WebPartPages:dataformparameter PropertyName="ParameterValues" ParameterKey="ListItemId" DefaultValue="0" Name="ListItemId">

</WebPartPages:dataformparameter><WebPartPages:dataformparameter PropertyName="ParameterValues" ParameterKey="ListID" DefaultValue="{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}" Name="ListID">

</WebPartPages:dataformparameter>

</InsertParameters><SelectParameters><WebPartPages:dataformparameter PropertyName="ParameterValues" ParameterKey="ListID" DefaultValue="{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}" Name="ListID">

</WebPartPages:dataformparameter>

</SelectParameters>

</SharePoint:SPDataSource>

</DataSources>

<ParameterBindings>

<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>

<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>

<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>

<ParameterBinding Name="ListID" Location="None" DefaultValue="{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}"/>

</ParameterBindings>

<datafields>@FileLeafRef,Nombre (para uso en formularios);@Title,Título;@_DCDateCreated,Fecha de creación;@ID,ID;@ContentType,Tipo de contenido;@Created,Creado;@Author,Creado por;@Modified,Modificado;@Editor,Modificado por;@_CopySource,Copiar origen;@CheckoutUser,Desprotegido para;@_CheckinComment,Comentario de protección;@CheckedOutTitle,Desprotegido para;@CheckedOutUserId,Id. del usuario que tiene desprotegido el elemento;@FileDirRef,Ruta;@FSObjType,Tipo de elemento;@HTML_x0020_File_x0020_Type,Tipo de archivo HTML;@File_x0020_Type,Tipo de archivo;@IsCheckedoutToLocal,Está desprotegido en local;@_SourceUrl,Dirección URL de origen;@_HasCopyDestinations,Tiene destinos de copia;@ContentTypeId,Id. de tipos de contenido;@_ModerationStatus,Estado de aprobación;@_UIVersion,Versión de IU;@Created_x0020_Date,Creado;@FileRef,Dirección URL;@File_x0020_Size,Tamaño de archivo;@_UIVersionString,Versión;@ParentVersionString,Versión del origen (documento convertido);@ParentLeafName,Nombre del origen (documento convertido);@TemplateUrl,Vinculo de la plantilla;</datafields>

<XSL>

<xsl:stylesheet

xmlns:x="http://www.w3.org/2001/XMLSchema"

xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"

version="1.0"

exclude-result-prefixes="dt s z rs 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"

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">

<xsl:output method="html" indent="no"/>

<xsl:decimal-format NaN=""/>

<xsl:param name="dvt_apos">'</xsl:param>

<xsl:param name="ListID">{2256D73A-FF33-4F07-A8E4-EBC8B69C47D9}</xsl:param>

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

<xsl:variable name="CountRow" select="count(//Row)" ></xsl:variable>

<xsl:variable name="listName" select="self::text"></xsl:variable>

<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">

<xsl:call-template name="dvt_1"/>

</xsl:template>

<xsl:template name="dvt_1">

<xsl:variable name="dvt_StyleName">Table</xsl:variable>

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>

<xsl:variable name="dvt_RowCount" select="count($Rows)" />

<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0" />

<xsl:choose>

<xsl:when test="$dvt_IsEmpty">

<xsl:call-template name="dvt_1.empty" />

</xsl:when>

<xsl:otherwise>

<xsl:call-template name="dvt_1.header">

<xsl:with-param name="Rows" select="$Rows"/>

</xsl:call-template>

<table border="0" width="100%" cellpadding="2" cellspacing="0">

<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="" align="left">

<input type="checkbox" id="chSelectAll">

<xsl:attribute name="onClick">javascript:SelectAllRow(<xsl:value-of select="$CountRow"></xsl:value-of>);</xsl:attribute>

</input>

</th>

<th class="ms-vh" nowrap="" align="left">Id</th>

<th class="ms-vh" nowrap="" align="left">Tipo</th>

<th class="ms-vh" nowrap="" align="left">Título</th>

<th class="ms-vh" nowrap="" align="left">Fecha Creación</th>

<th class="ms-vh" nowrap="" align="left">Creado por</th>

<th class="ms-vh" nowrap="" align="left">Modificado por</th>

</tr>

<xsl:call-template name="dvt_1.body">

<xsl:with-param name="Rows" select="$Rows"/>

</xsl:call-template>

</table></xsl:otherwise>

</xsl:choose>

</xsl:template>

<xsl:template name="dvt_1.body">

<xsl:param name="Rows"/>

<xsl:for-each select="$Rows">

<xsl:call-template name="dvt_1.rowview">

<xsl:with-param name="Pos" select="concat(‘_’, position())" />

</xsl:call-template>

</xsl:for-each>

</xsl:template>

<xsl:template name="dvt_1.rowview">

<xsl:param name="Pos" />

<tr>

<xsl:attribute name="id">row<xsl:value-of select="$Pos"></xsl:value-of></xsl:attribute>

<xsl:if test="position() mod 2 = 1">

<xsl:attribute name="class">ms-alternating</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="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>

</td>

</xsl:if>

<td class="ms-vb">

<input type="checkbox">

<xsl:attribute name="id">chk<xsl:value-of select="$Pos"></xsl:value-of></xsl:attribute>

<xsl:attribute name="onclick">javascript:SelectRow(‘<xsl:value-of select="$Pos"></xsl:value-of>’);</xsl:attribute>

</input>

</td>

<td class="ms-vb" align="left">

<xsl:value-of select="format-number(@ID, ‘#,##0.#;-#,##0.#’)"/>

</td>

<td class="ms-vb" align="left">

<xsl:if test="@DocIcon=’docx’">

<img border="0" src="../Demo_3_Final/icdocx.gif" width="16" height="16" />

</xsl:if>

<xsl:if test="@DocIcon=’doc’">

<img border="0" src="_layouts/images/icdocx.gif" width="16" height="16" />

</xsl:if>

<xsl:if test="@DocIcon=’xlsx’">

<img border="0" src="_layouts/images/icxlsx.gif" width="16" height="16" />

</xsl:if>

<xsl:if test="@DocIcon=’xls’">

<img border="0" src="_layouts/images/icxlsx.gif" width="16" height="16" />

</xsl:if>

</td>

<td class="ms-vb" align="left">

<a>

<xsl:attribute name="href"><xsl:value-of select="@FileRef"></xsl:value-of></xsl:attribute>

<xsl:value-of select="@Title"/>

</a>

</td>

<td class="ms-vb" align="left">

<xsl:value-of select="ddwrt:FormatDate(string(@_DCDateCreated), 3082, 1)"/>

</td>

<td class="ms-vb" align="left">

<xsl:value-of select="@Author" disable-output-escaping="yes"/>

</td>

<td class="ms-vb" align="left">

<xsl:value-of select="@Editor" disable-output-escaping="yes"/>

</td>

</tr>

</xsl:template>

<xsl:template name="dvt_1.header">

<xsl:param name="Rows" />

<table cellSpacing="0" class="ms-menutoolbar" cellPadding="0" border="0" width="100%">

<tr>

<td class="ms-toolbar" width="80%">

Documentos de la lista</td>

<td class="ms-toolbar" align="left" width="20%"><xsl:value-of select="count(/dsQueryResponse/Rows/Row)" />

documentos activos

<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>

</td>

</tr>

</table>

</xsl:template>

<xsl:template name="dvt_1.empty">

<xsl:variable name="dvt_ViewEmptyText">No hay elementos que mostrar en esta vista.</xsl:variable>

<table border="0" width="100%">

<tr>

<td class="ms-vb">

<xsl:value-of select="$dvt_ViewEmptyText" />

</td>

</tr>

</table>

</xsl:template>

</xsl:stylesheet>

</XSL>

</WebPartPages:DataFormWebPart>

</asp:Content>

<asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderAdditionalPageHead">

Muchas gracias a los que asistieron y nos hicieron llegar sus comentarios………

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *