Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a page that I'm provisioning in Visual Studio 2010 through a module. In my elements.xml I have a <File> element with a <View> element underneath like this:

<File Path="TemplatePage.aspx" Url="Edit_Pages/Links.aspx" Type="GhostableInLibrary" >    
  <View List="Lists/Links" BaseViewID="1" WebPartZoneID="Left" WebPartOrder="2" />
</File>

The view looks at a list of links. Everything goes fine with the provisioning but when I go to the page and click on the webpart the "Change Item Order" option under the ribbon "List Tools -> Items" is disabled. However, if I go to the list directly through "View All Site Content", the option is enabled. My question is "How can I enable the Change Item Order button?".

Change Item Order Disabled

share|improve this question
add comment

2 Answers

That option is enabled normally only on Links and Meeting Workspaces. E. Struyf has an excellent series on how to customize any list to support it here http://www.estruyf.be/blog/order-list-items-like-in-a-meeting-workspace-part-1/ For a list instance based on the TemplateType=103 (LINKS)

<ListInstance Title="Global Links"
                OnQuickLaunch="TRUE"
                TemplateType="103"
                FeatureId="00bfea71-2062-426c-90bf-714c59600103"
                Url="GlobalLinks" RootWebOnly="TRUE"
                Description="Use this list to store links with Global scope"/>

Inserting a ListView while provisioning the page should be achieved like this

<View BaseViewID="9" List="GlobalLinks" WebPartZoneID="Left" WebPartOrder="1" DisplayName="Global Links" >
        <![CDATA[
          <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
              <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
              <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
              <Title>My Requests</Title>
              <Toolbar>None</Toolbar>
              <NoAnnouncements>You have no links available.</NoAnnouncements>
          </WebPart>
        ]]>

      </View>
share|improve this answer
    
This IS a "Links" list. That's why it works automatically when I go to the list from the "View All Site Content" page. However, I'm putting the list on another page as well and I would like the user to be able to do it there. –  skeletank Apr 25 '12 at 17:13
    
If you use the OOTB ListView web-part in a page you should get this functionality in the Ribbon under the Items tab (as usual) - just checked (you need at least 1 item)! I've added to my answer an example of the List Instance for Links! –  C. Marius - MVP Apr 25 '12 at 17:20
    
Sorry, I just added my xml to my question. As you can see I'm using my own page with a view of the list in addition to the page that is automatically provisioned when you use the xml from the answer you provided. –  skeletank Apr 25 '12 at 17:29
    
I use the 1st bit to create a list instance which can be used in features. The 2nd part of the code, shows how you can provision via Module a page with a View embed in it (which I believe your intention is). –  C. Marius - MVP Apr 25 '12 at 17:36
    
My example in the question also provisions via Module a page with an embedded view. Have you tested your version to make sure that "Change Item Order" is available on that provisioned page? I'm not meaning to be rude but I was wondering what the difference between mine and yours would be that allows yours to see that option. When I look at the view for my webpart the "Allow users to order items in this view?" option is set to "No" after provisioning. –  skeletank Apr 25 '12 at 17:40
add comment
up vote 2 down vote accepted

I found a technique to set the "Allow users to order items in this view?" property for the webpart. I call this method from the feature receiver of my provisioning feature. The key is setting the XsltListViewWebPart.ViewFlags to include SPViewFlags.Ordered. Here is the forum entry answer by Porter Wang which led me to my solution.

SPList list = web.Lists[listName];
SPFile file = web.GetFile(pageUrl);
file.CheckOut();

SPLimitedWebPartManager webPartManager = 
  file.GetLimitedWebPartManager(PersonalizationScope.Shared);

XsltListViewWebPart selectedWebPart = (XsltListViewWebPart)
  (from Microsoft.SharePoint.WebPartPages.WebPart webPart in webPartManager.WebParts
   where webPart is XsltListViewWebPart && webPart.ZoneIndex == webPartZoneOrder
   select webPart).FirstOrDefault();

if ((selectedWebPart.ViewFlags & SPViewFlags.Ordered) == 0)
  selectedWebPart.ViewFlags = selectedWebPart.ViewFlags | SPViewFlags.Ordered;

webPartManager.SaveChanges(selectedWebPart);
web.Update();

file.CheckIn(String.Empty);
file.Publish(String.Empty);
file.Approve(String.Empty);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.