SharePoint【学习笔记】-- 树视图:隐藏SPTreeView个别项

母版页树视图默认情况下会显示所有内容类型,项目需要只显示指定几个文档库的树视图,操作如下: 

1.显示类型控制,减少下一步脚本工作量

参考: http://www.cnblogs.com/hanaimin/archive/2008/04/11/1148929.html

通过设置ShowWebChildren,ShowListChildren,ShowFolderChildren,ShowDocLibChildren达到只显示文档库类型的目的:

<SharePoint:SPHierarchyDataSourceControl runat="server" id="TreeViewDataSourceV4" RootContextObject="Web" IncludeDiscussionFolders="false" ShowWebChildren="False" ShowListChildren="False" ShowFolderChildren="true" ShowDocLibChildren="True" /> 

 

2.通过Jquery设定要显示的文档库名称

参考:http://www.cnblogs.com/zxtingfeng/archive/2012/08/27/2658211.html

<script type="text/javascript"> 

      

function hiddenTreeView() { try { //var tree = $("#ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewV4"); 

        //var tables=tree.children("table"); 

        //var trs = tree.getElementsByTagName("TR"); 

        var tds=$("#ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewV4>table>tbody>tr>td[class*='ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewV4_2']") for (var i = 0; i < tds.length; i++) { if(tds[i].outerText== "文档"||tds[i].outerText== "ISO发布文档库"||tds[i].outerText== "样式库" ) { continue; } else { $(tds[i]).parents('table').hide(); $(tds[i]).parents('table').next('div').hide(); } } } catch (e) { } } hiddenTreeView(); </script>

 

你可能感兴趣的:(SharePoint)