Aimin Han

SharePoint Server、Office、Silverlight、Flash、GIS、AVEVA NET & solutions 培训 咨询 设计
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

SharePoint2007树视图定制:浏览SPList节点下的内容

Posted on 2008-04-11 19:37  aimin  阅读(1951)  评论(9编辑  收藏  举报
    树视图在Web平台中是一种常见的菜单视图,特别是文档层级树目录结构的应用。在SharePoint2007中所推崇使用的快速启动由于只能配置2级菜单,很多时候不能满足要求。用Designer研究了一下树控件部分的页面代码。发现有几个关键属性似乎可以定制:rootContextObjet(应该是根节点的类型)、RootListId(根列表节点)、RootWebId(根站点节点)。但是默认情况下,rootContextObject=“Web”,其它值查遍文档也没有发现(郁闷....),RootListId和RootWebId都是空的,或者是"0000-0000。。。。"。 
显然,rootContextObject不能是"Web",随便猜着试用了“List”、“SPList”都不行,不得已求助于Reflector,发现rootContextObject有三种判断,"Web"、"List"和空。而"List"显然是代码运行时产生的。我试了赋值rootContextObject=“List”果然不行。就干脆把rootContextObject删掉。OK了。

如果要显示多个列表,可以如下:使用多个树控件和层级数据源。代码如下:

 1 <div class="ms-treeviewouter">
 2                    <SharePoint:SPHierarchyDataSourceControl
 3                     runat="server"
 4                     id="TreeViewDataSource"
 5                     RootListId="ff1af9a7-daac-42fe-b9e3-26f08c8992e7"
 6                     RootWebId="83d09d8e-484e-4020-8b64-d2ee993df38c"
 7                     IncludeDiscussionFolders="true"
 8                    />
 9                    <SharePoint:SPHierarchyDataSourceControl
10                     runat="server"
11                     id="TreeViewDataSource1"
12                     RootListId="4068d162-02fc-46fe-9490-78e451c9e377"
13                     RootWebId="83d09d8e-484e-4020-8b64-d2ee993df38c"
14                     IncludeDiscussionFolders="true"
15                    />
16
17                    <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll" onscroll="javascript:_spRecordScrollPositions(this);" Style="overflow: auto;height: 400px;width: 150px; ">
18                    <Sharepoint:SPTreeView
19                        id="WebTreeView"
20                        runat="server"
21                        ShowLines="false"
22                        DataSourceId="TreeViewDataSource"
23                        ExpandDepth="0"
24                        SelectedNodeStyle-CssClass="ms-tvselected"
25                        NodeStyle-CssClass="ms-navitem"
26                        NodeStyle-HorizontalPadding="2"
27                        SkipLinkText=""
28                        NodeIndent="12"
29                        ExpandImageUrl="/_layouts/images/tvplus.gif"
30                        CollapseImageUrl="/_layouts/images/tvminus.gif"
31                        NoExpandImageUrl="/_layouts/images/tvblank.gif"
32                    >
33                    </Sharepoint:SPTreeView>
34                    <Sharepoint:SPTreeView
35                        id="WebTreeView1"
36                        runat="server"
37                        ShowLines="false"
38                        DataSourceId="TreeViewDataSource1"
39                        ExpandDepth="0"
40                        SelectedNodeStyle-CssClass="ms-tvselected"
41                        NodeStyle-CssClass="ms-navitem"
42                        NodeStyle-HorizontalPadding="2"
43                        SkipLinkText=""
44                        NodeIndent="12"
45                        ExpandImageUrl="/_layouts/images/tvplus.gif"
46                        CollapseImageUrl="/_layouts/images/tvminus.gif"
47                        NoExpandImageUrl="/_layouts/images/tvblank.gif"
48                    >
49                    </Sharepoint:SPTreeView>
50
51                    </Sharepoint:SPRememberScroll>
52                  </div>
53