WSS 3 / MOSS Creating Views in CAML (List Definition)

本文探讨了在使用CAML进行列表定义时,如何正确配置视图以避免常见问题,特别是关于BaseViewID的设置及其对ListViewWebPart的影响。

I have been creating custom Lists in CAML for deployment by features.  As you do.  I found out a few things that might be of help when you are creating them yourselves.

I am  Assuming that you now how to create a list template and know what goes in a schema.xml to a point.

Concentrating solely on views here I found out this.

If you have a List View WebPArt you need one of these types of views, if you don’t LVWP don’t work.

<View BaseViewID="0" Type="HTML">….</View>

Careful of BaseViewIDs being the same.

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary" Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

<View SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary"  Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

Notice that the BaseViewID’s, that wonderful field that’s barely documented, if they are both the same number then you might get problems.  I can’t explain why, but In my views I created the second view had a different Query but was ignored when created and it copied the first views query.  When I changed the BaseViewID=2 on the second view everything worked.

Is that the right thing to do ? I can’t say I’m only commenting on what I have observed.

Don’t do this

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary" Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

<View DefaultView="TRUE" SetupPath="pages\viewpage.aspx" Type="HTML" DisplayName="Summary"  Url="Summary.aspx" Level="1" BaseViewID="1" ContentTypeID="0x"
            ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main">

If you forget when you cut and paste if you have two default views in the "Lists" page it shows up twice, its not really there twice but looks like it is.  You may not notice till too late with this one.

 

References:http://www.binaryjam.com/2008/11/06/wss-3-moss-creating-views-in-caml-list-definition/

转载于:https://www.cnblogs.com/KingStar/archive/2010/11/30/1891762.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值