Wednesday, December 19, 2007
Move SharePoint 2007 paging control from the right to the left of the action bar.
A user at my workplace has a view that is horizontally very wide. It drives him nuts to have to scroll all the way to the extreme right of the page in order to find the paging control. He pleaded with me to find a way to move this control to the left side of the action bar. After many hours of research, here's what I found:
The default layout of the action bar is defined in a user control file named DefaultTemplates.ascx found in the TEMPLATE\CONTROL TEMPLATES directory of your 12-hives
The default layout can be alterted for a particular type of list be over-riding the "ViewToolBar" for that list.
This is best done by working on a copy of DefaultTemplates.ascx
I moved the paging control for the DocumentLibraryViewToolBar to the left-hand-side by doing the following:
copy DefaultTemplates.ascx to PagingLeftOnDocLibrary.ascx (or any other name you fancy).
open PagingLeftOnDocLibrary.ascx in a text editor
search for DocumentLibraryViewToolBar. Your editor should find this line: <SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">
delete all <SharePoint:RenderingTemplate>.. </SharePoint:RenderingTemplate> sections before and after the section that you have just found. In other words retain the section <SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server"> .. </SharePoint:RenderingTemplate> and delete all other sections
You will be left with only the following:
<%@ Control Language="C#" AutoEventWireup="false" %>
<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">
<Template>
<wssuc:ToolBar
CssClass="ms-menutoolbar"
EnableViewState="false"
id="toolBarTbl"
ButtonSeparator="<img src='/_layouts/images/blank.gif'
alt=''>" RightButtonSeparator=" "
runat="server">
<Template_Buttons>
<SharePoint:NewMenu AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server"/>
<SharePoint:UploadMenu AccessKey="<%$Resources:wss,tb_UploadMenu_AK%>" runat="server"/>
<SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/>
<SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>
</Template_Buttons>
<Template_RightButtons>
<SharePoint:PagingButton runat="server"/>
<SharePoint:ListViewSelector runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</Template>
</SharePoint:RenderingTemplate>
The PagingButton section (shown in red above) needs to be moved to the Template_Buttons section. I simply cut <SharePoint:PagingButton runat="server"/> and pasted it right before </Template_Buttons>
If you restart IIS (IISRESET from the command line) you should see the paging control on the left-hand-side of the document library action bar as shown below.
The final version of my PagingLeftOnDocLibrary.ascx is:
<%@ Control Language="C#" AutoEventWireup="false" %>
<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
<%@Register TagPrefix="SPHttpUtility" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Utilities"%>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<SharePoint:RenderingTemplate ID="DocumentLibraryViewToolBar" runat="server">
<Template>
<wssuc:ToolBar
CssClass="ms-menutoolbar"
EnableViewState="false"
id="toolBarTbl"
ButtonSeparator="<img src='/_layouts/images/blank.gif'
alt=''>" RightButtonSeparator=" "
runat="server">
<Template_Buttons>
<SharePoint:NewMenu AccessKey="<%$Resources:wss,tb_NewMenu_AK%>" runat="server"/>
<SharePoint:UploadMenu AccessKey="<%$Resources:wss,tb_UploadMenu_AK%>" runat="server"/>
<SharePoint:ActionsMenu AccessKey="<%$Resources:wss,tb_ActionsMenu_AK%>" runat="server"/>
<SharePoint:SettingsMenu AccessKey="<%$Resources:wss,tb_SettingsMenu_AK%>" runat="server"/>
<SharePoint:PagingButton runat="server"/>
</Template_Buttons>
<Template_RightButtons>
<SharePoint:ListViewSelector runat="server"/>
</Template_RightButtons>
</wssuc:ToolBar>
</Template>
</SharePoint:RenderingTemplate>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment