Question

I've got a custom site definition with a list definition + list instance in it. In the schema.xml for the list, I tried adding multiple views for the list. The problem I have is that although the custom views are being deployed, some properties seem to be ignored for some reason.

For example; I have defined some other ViewFields to be shown in one of the non-default views. But after deployment, that custom view shows exactly the same columns as the default view has. Same goes for the Query, that isn't deployed as well.

Here's my view def:

<View Name="{5BB1D385-0E92-42D0-8348-8E81F90D2688}" MobileView="TRUE" Type="HTML" 
        DisplayName="Verzonden orders" Url="VerzondenOrders.aspx" 
        BaseViewID="1" ImageUrl="/_layouts/images/generic.png"
        SetupPath="pages\viewpage.aspx">
    <ViewFields>
      <FieldRef Name="Attachments" />
      <FieldRef Name="Ordernummer" />
      <FieldRef Name="Commissie" />
      <FieldRef Name="Datum_x0020_besteld" />
      <FieldRef Name="Datum_x0020_verzonden" />
      <FieldRef Name="Order_x0020_status" />
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Ordernummer" />
      </OrderBy>
      <Where>
        <Eq>
          <FieldRef Name="Order_x0020_status" />
          <Value Type="Text">Verzonden</Value>
        </Eq>
      </Where>
    </Query>
    <RowLimit Paged="TRUE">30</RowLimit>
    <XslLink Default="TRUE">main.xsl</XslLink>
    <Toolbar Type="Standard" />
  </View>

Who can help me out?

Was it helpful?

Solution

Do you have a unique BaseViewID for every view?

I noticed that in your sample view that the Url attribute is VerzondenOrders.aspx and the BaseViewID attribute is 1. Usually 1 is the BaseViewID of AllItems.aspx. If you copy and pasted your custom views from AllItems.aspx, you need to make sure to change the BaseViewID in addition to the URL and DisplayName.

I suppose that it is possible that if all your views have a BaseViewID of 1 that SharePoint is using the ViewFields definition from the first entry (AllItems.aspx), which could explain the behavior you are seeing.

OTHER TIPS

Not sure if you have manually created your xml, but one way to find errors is to design the list through the browser first, then save the site as a template through site setting (/_layouts/savetmpl.aspx), download the wsp from the solution gallery, extract the files from it, and compare your schema.xml against the schema.xml in the wsp.

How did you create the view? Did you export the schema from an existing site or copy an existing view? I recommend exporting either site or list as template, open them in Visual Studio (import site) and get the view from there.

Also do the fields exist in the content type?

Do the columns defined in the ViewFields exist in the list definition. And are these columns created when the list is created?

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top