开发者

ListViewWebPart problem with custom Event list template

I have copied C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\EventsList\Events\schema.xml into a custom list template feature. I have another feature that creates the list instance:

<ListInstance
    FeatureId="58c1f9c9-eadb-41dd-a358-e04b2f2e30c0"
    TemplateType="100322"
    Title="$Resources:core,calendarList"
    Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder"
    OnQuickLaunch="TRUE">
</ListInstance>

and then places a ListViewWebPart on the page:

<View List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder" BaseViewID="0" WebPartZoneID="Top开发者_开发知识库RightRow" WebPartOrder="3" />

I activate the features and go to the site. The webpart says: There are currently no upcoming events. To add a new event, click "Add new event". I click Add new event, enter the information, and click Save. The page refreshes, the no upcoming events message disappears, but there are no items displayed! If I go to the calendar the list item is there. What gives?

I change the list instance definition so that it uses the out of the box template:

<ListInstance
    FeatureId="00bfea71-ec85-4903-972d-ebe475780106"
    TemplateType="106
    Title="$Resources:core,calendarList"
    Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder"
    OnQuickLaunch="TRUE">
</ListInstance>

When I rebuild the site, activate the features, and repeat the "add new" steps, the item is now displaying properly in the webpart after the page refresh.

I've backed out all of my changes from the custom list template. It is now identical to the OOTB schema. Why doesn't my custom list template work, but the OOTB list template does?


I have know idea why the OOTB template works, but I was able to fix my custom template.

First, remove the XslLink line from the BaseViewID="0" View in schema.xml:

<XslLink>main.xsl</XslLink>

Scroll down to the Toolbar/IfHasRights section. Change Case 4 from:

<Case Value="4"><HTML><![CDATA[<div class="tb"><img src="/_layouts/images/caladd.gif" alt="" />&#160;<a class="ms-addnew" id="idHomePageNewEvent" href="]]></HTML>
  <URL Cmd="New" /><HTML><![CDATA[" onclick="javascript:NewItem(']]></HTML>
  <ScriptQuote NotAddingQuote="TRUE">
    <URL Cmd="New" />
  </ScriptQuote><HTML><![CDATA[', true);javascript:return false;" target="_self">]]></HTML><HTML>$Resources:core,AddNewEvent;</HTML><HTML><![CDATA[</a></div>]]></HTML>
</Case>

to:

<Case Value="4"><HTML><![CDATA[<div class="tb"><img src="/_layouts/images/caladd.gif" alt="" />&#160;<a class="ms-addnew" id="idHomePageNewEvent" href="]]></HTML>
  <URL Cmd="New" /><HTML><![CDATA[" onclick="javascript:NewItem2(event, ']]></HTML>
  <ScriptQuote NotAddingQuote="TRUE">
    <URL Cmd="New" />
  </ScriptQuote><HTML><![CDATA[');javascript:return false;" target="_self">]]></HTML><HTML>$Resources:core,AddNewEvent;</HTML><HTML><![CDATA[</a></div>]]></HTML>
</Case>

This enables the new SharePoint 2010 popup NewForm.aspx behavior.

Next, change the provisioning of the webpart to:

<View List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder" BaseViewID="0" WebPartZoneID="TopRightRow" WebPartOrder="3">
    <![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>Calendar</Title>                       
        </WebPart>
    ]]>
</View>

This along with the removal of the XslLink line forces the webpart to render as a ListViewWebPart instead of as an XsltListViewWebPart.

Now the rendering between the two weparts is different, so as a last step, use the following style so that the add new link of the ListViewWebPart looks like the add new link of the XsltListViewWebPart:

div.tb {
border-top:1px solid #EBEBEB;
margin:3px 0 16px;
padding:9px 7px 3px 10px;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜