none
How to add XSLT List View Web Part (XLV) to the applicaton page (to _layouts folder)?

    Question

  • Is there a way to add XSLT List View Web Part (XLV) to the application page (in _layouts folder)?


    I need to create a settings page (adding a link using Custom action is done) that displays a list with pedefined name for every site in the site collection.
    A need to show it with customized view using XSLT.
    XSLT List View Web Part (XLV) looks like a good solution.
    Creating a site page for every site seems to be overkill.
    Moreover, I don't want a user to be able to delete the web part from the page.
    So, my choice would be to use application page. Using SPGridView also would be a lot of overhead.
    As a temporary solution I use LISTNAME/AllItems.aspx page. However, Still need to run some code behing on the page.

    2. Is there equivalent asp control for XSLT List View Web Part (XLV) that I could use (instead of web part)? Any example?

    Thank you,


    Oleg Slyusarchuk
    Monday, May 23, 2011 11:37 PM

Answers

  • You can use SharePoint Designer to inspect the code of your AllItems.aspx page and see what she use.

    For example:

    Register the controls on Page:

    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
      Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    

    Put XsltViewWebPart on application page:

    <WebPartPages:XsltListViewWebPart runat="server" Description="" ListDisplayName=""
        ImportErrorMessage="Cant view this webpart" PartOrder="2" Default="TRUE" HelpLink=""
        AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True"
        ExportControlledProperties="False" IsIncludedFilter="" DataSourceID="" Title="TestList"
        ViewFlag="25165829" NoDefaultStyle="" AllowConnect="True" DisplayName="All items"
        PageType="PAGE_DEFAULTVIEW" FrameState="Normal" PageSize="-1" PartImageLarge=""
        AsyncRefresh="False" Dir="Default" DetailLink="/testsite/Lists/TestList" ShowWithSampleData="False"
        ListId="<strong>{YOU LIST ID}</strong>" ListName="List name" FrameType="Default" PartImageSmall=""
        IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" AutoRefresh="False"
        AutoRefreshInterval="60" AllowMinimize="True" ViewContentTypeId="0x" InitialAsyncDataFetch="False"
        GhostedXslLink="main.xsl" MissingAssembly="Cant view this webpart" HelpMode="Modeless"
        ListUrl="" ID="g_1127c44d_1b32_4510_bc40_4899f6ec217c" ConnectionID="00000000-0000-0000-0000-000000000000"
        AllowZoneChange="True" TitleUrl="/testsite/Lists/TestList" ManualRefresh="False"
        __MarkupType="vsattributemarkup" __WebPartId="{1127C44D-1B32-4510-BC40-4899F6EC217C}"
        __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_EmailField.xsl;fldtypes_Ratings.xsl"
        WebPart="true" Height="" Width="">
        <ParameterBindings>
    			<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
    			<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
    			<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
    			<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
    			<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
    			<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
    			<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
    			<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
    			<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
    			<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
        <XmlDefinition>
    			<View Name="" 
          DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" 
          DisplayName="All items" Url="" 
          Level="1" BaseViewID="1" ContentTypeID="0x" 
          ImageUrl="/_layouts/images/generic.png">
    				<Query>
    					<OrderBy>
    						<FieldRef Name="ID"/>
    					</OrderBy>
    				</Query>
    				<ViewFields>
    					<FieldRef Name="Attachments"/>
    					<FieldRef Name="LinkTitle"/>
    					<FieldRef Name="Email"/>
    				</ViewFields>
    				<RowLimit Paged="TRUE">30</RowLimit>
    			</View>
        </XmlDefinition>
        <DataFields>
        </DataFields>
      </WebPartPages:XsltListViewWebPart>
    

     

     

    Tuesday, May 24, 2011 5:01 AM

All replies

  • If you simply want to display a list you have a lot of simple options. Since it is an application page, the simplest approach is to add an inline code block that iterates the AllWebs property of the SPContext.Current.Site with a for loop calling Response.Write for each web.

    If that won't work, please provide a little more information about your requirements.

    --Doug 

    Monday, May 23, 2011 11:51 PM
  • Thank you, Doug

    I need to display everything that lists/myListName/AllItems.aspx page shows: every option available to display list items: paging/sorting/filtering/grouping, multiple views.
    on top of that, I'll use some of XSLT enhancements (like conditional coloring ).

    Your solution would be too simple :) 

    Oleg Slyusarchuk
    Tuesday, May 24, 2011 12:05 AM
  • But this could be for any list on any web?
    Tuesday, May 24, 2011 12:15 AM
  • You can use SharePoint Designer to inspect the code of your AllItems.aspx page and see what she use.

    For example:

    Register the controls on Page:

    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
      Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    

    Put XsltViewWebPart on application page:

    <WebPartPages:XsltListViewWebPart runat="server" Description="" ListDisplayName=""
        ImportErrorMessage="Cant view this webpart" PartOrder="2" Default="TRUE" HelpLink=""
        AllowRemove="True" IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True"
        ExportControlledProperties="False" IsIncludedFilter="" DataSourceID="" Title="TestList"
        ViewFlag="25165829" NoDefaultStyle="" AllowConnect="True" DisplayName="All items"
        PageType="PAGE_DEFAULTVIEW" FrameState="Normal" PageSize="-1" PartImageLarge=""
        AsyncRefresh="False" Dir="Default" DetailLink="/testsite/Lists/TestList" ShowWithSampleData="False"
        ListId="<strong>{YOU LIST ID}</strong>" ListName="List name" FrameType="Default" PartImageSmall=""
        IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" AutoRefresh="False"
        AutoRefreshInterval="60" AllowMinimize="True" ViewContentTypeId="0x" InitialAsyncDataFetch="False"
        GhostedXslLink="main.xsl" MissingAssembly="Cant view this webpart" HelpMode="Modeless"
        ListUrl="" ID="g_1127c44d_1b32_4510_bc40_4899f6ec217c" ConnectionID="00000000-0000-0000-0000-000000000000"
        AllowZoneChange="True" TitleUrl="/testsite/Lists/TestList" ManualRefresh="False"
        __MarkupType="vsattributemarkup" __WebPartId="{1127C44D-1B32-4510-BC40-4899F6EC217C}"
        __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_EmailField.xsl;fldtypes_Ratings.xsl"
        WebPart="true" Height="" Width="">
        <ParameterBindings>
    			<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
    			<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
    			<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
    			<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
    			<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
    			<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
    			<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
    			<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
    			<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
    			<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
        <XmlDefinition>
    			<View Name="" 
          DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" 
          DisplayName="All items" Url="" 
          Level="1" BaseViewID="1" ContentTypeID="0x" 
          ImageUrl="/_layouts/images/generic.png">
    				<Query>
    					<OrderBy>
    						<FieldRef Name="ID"/>
    					</OrderBy>
    				</Query>
    				<ViewFields>
    					<FieldRef Name="Attachments"/>
    					<FieldRef Name="LinkTitle"/>
    					<FieldRef Name="Email"/>
    				</ViewFields>
    				<RowLimit Paged="TRUE">30</RowLimit>
    			</View>
        </XmlDefinition>
        <DataFields>
        </DataFields>
      </WebPartPages:XsltListViewWebPart>
    

     

     

    Tuesday, May 24, 2011 5:01 AM
  • I need to create an application page  that displays rows (records, list items) from a list with pedefined name for every site in the site collection.
    More precisely:
    I have a list named "Results". Every time I run a process (which I start from another application page), let's name the process Export,  a new row (list item) will be created in the results list.
    When export completes, i redirect a user to a page where I show the most recent result of the process (along with old results). 
    I need to be able sort/group/ etc. rows of this.

    To answer your question: Yes, the page should be able to display any list of any web. What to show can be configurable based on the query string value/business logic.

    In my case, page display a list with predefined name (Results). From which web/site will depend on the Url before _layouts (the way an application page finds its context).
     
     


    Oleg Slyusarchuk
    Tuesday, May 24, 2011 5:02 AM
  • 	Thank you, red commander
    
    The essence of the issue was the following:
    
    - NOT include a reference too <WebPartPages:SPWebPartManager id="m" runat="Server"/>
    - NOT define web zones
    - import AllItems.aspx page WITHOUT refering a particular web (WebId ="00000000-0000-0000-0000-000000000000")
    
    Fisrt 2 all specifics of application page, while the last makes the web part independent of the web.

    Oleg Slyusarchuk
    Tuesday, May 24, 2011 6:39 PM
  • Oleg,

    I did a quick blog post http://shaunedonohue.blogspot.com/2011/10/how-to-change-view-used-by.html on adding a query string to the app page so I could programmaticly change the list and view used by the XLVWP.

    Don't know if it will help but there you go.

     

    Shaune

     


    Shaune
    Wednesday, November 02, 2011 2:02 PM