list 如何嵌入web part
我有一个自定义的list instance 一个web part , 如何把这个list放到这个web part中,我不想每次部署完了再在网页上添加这个list
[解决办法]
加在你的list的Schema.xml里面
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<RowLimit Paged="TRUE">30</RowLimit>
<ViewFields>
<FieldRef Name="LinkTitleNoMenu" />
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="fld_News_IsSetTop" Ascending="FALSE" />
<FieldRef Name="ID" Ascending="FALSE" />
</OrderBy>
</Query>
<Aggregations Value="Off" />
<RowLimit Paged="TRUE">3</RowLimit>
<Mobile MobileItemLimit="3" MobileSimpleViewField="LinkTitleNoMenu" />
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</ParameterBindings>
<WebParts>
<AllUsersWebPart WebPartZoneID ="Main" WebPartOrder ="0">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="HSCN.Portal.WebParts.WPNewsWithSummaryList.WPNewsWithSummaryList, HSCN.Portal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7f793e4fc1f413f" />
<importErrorMessage>无法导入此 Web 部件。</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ChromeType" type="chrometype">None</property>
<property name="Height" type="unit" />
<property name="AllowZoneChange" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="TitleLength" type="int">40</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="AllowConnect" type="bool">True</property>
<property name="AllowClose" type="bool">True</property>
<property name="HelpMode" type="helpmode">Navigate</property>
<property name="Hidden" type="bool">False</property>
<property name="Title" type="string">新闻中心摘要视图显示部件</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowHide" type="bool">True</property>
<property name="RowCount" type="int">3</property>
<property name="ListSortField" type="string" null="true" />
<property name="Description" type="string">用于新闻中心视图页面显示标题、摘要信息等内容</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="TitleUrl" type="string" />
<property name="ShowNewIconDay" type="int">2</property>
<property name="Width" type="unit" />
<property name="SummaryLength" type="int">240</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="Direction" type="direction">NotSet</property>
<property name="HelpUrl" type="string" />
<property name="TitleIconImageUrl" type="string" />
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>
</WebParts>
</View>
[解决办法]
你把这个webpart随便找个页面一放, 然后编辑页面,编辑这个webpart, 高级, 导出模式选择导出所有数据,然后导出这个Webpart, 再把这个webpart用记事本打开,里面的文本就是
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="HSCN.Portal.WebParts.CommonLinks.CommonLinks, HSCN.Portal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c7f793e4fc1f413f" />
<importErrorMessage>无法导入此 Web 部件。</importErrorMessage>
</metaData>
<data>
<properties>
<property name="AllowZoneChange" type="bool">True</property>
...
</properties>
</data>
</webPart>
</webParts>这些
,放到你的list definition的Schema文件里去。