隐藏文档库SPTreeView个别项

在模板页中 <SharePoint:DelegateControl runat="server" ControlId="TreeViewAndDataSource">DelegateControl是代理,指向C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\MetadataNavTree.ascx,必须修改MetadataNavTree.ascx。

js自下而上加载,

View Code
<script type="text/javascript">
    
function hiddenTreeView() {
    try {
        var tree = document.getElementById("ctl00_PlaceHolderLeftNavBar_ctl01_ctl01_WebTreeView");
        var trs = tree.getElementsByTagName("TR");

        for (var i = 0; i < trs.length; i++) {
            var tds = trs[i].getElementsByTagName("TD");

            if (tds.length == 3) {
                if (tds[2].outerText != "文档") {
                    tds[0].style.display = "none";
                    tds[1].style.display = "none";
                    tds[2].style.display = "none";
                }
            }
        }
    }
    catch (e) {
    } 
}
window.onload = hiddenTreeView; 

    </script>

 

如果是所有导航都要修改

<SharePoint:SPHierarchyDataSourceControl runat="server"
 		ID="TreeViewDataSource"
		RootWebId="2633d437-e704-4766-94ae-325acff9c987" //web GUID
		RootListId="110db205-d8b8-460e-8fed-8f7f875cd314"//List GUID 
		IncludeDiscussionFolders="true"
		ShowListChildren="true" />

 

posted on 2012-08-27 11:15  瓶装的生活  阅读(471)  评论(0编辑  收藏  举报