Tab with web parts in Sharepoint 2013

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   strong   for   

 Tab with web parts in Sharepoint 2013

 

Implement a feature about tabbing content with multiple web parts, each associated with a header in a list. I will achieve it in SharePoint 2013.

to tab select web parts, I can regared the web part zone as a div, and all the web parts should be single panel. here is my steps:

1. create a page layout

2. add a div as a container, In this div, append a div as a title to switch button
 <div class="sp-content-up">            <div class="tab ms-webpart-titleText">            </div>            <div class="clear"></div>            <div data-name="WebPartZone">                <!--CS: Start Web Part Zone Snippet-->                <!--SPM:<%@Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->                <div xmlns:ie="ie">                    <!--MS:<WebPartPages:WebPartZone runat="server" AllowPersonalization="false" ID="x774799e39f4841a58494c7cdf6dd1b4f" FrameType="TitleBarOnly" Orientation="Vertical">-->                    <!--MS:<ZoneTemplate>-->                    <!--DC: Replace this comment with default web parts for new pages. -->                    <!--ME:</ZoneTemplate>-->                    <!--ME:</WebPartPages:WebPartZone>-->                </div>                <!--CE: End Web Part Zone Snippet-->            </div> </div>
3. cretae a page using the new page layout, and add serveral web parts in the page.4. add css and js using Script Edit web part in the new page
<script> $(document).ready(function(){$(".sp-content-up .ms-webpart-titleText").find("span").each(function(){if( this.innerHTML !="" && this.innerHTML !=undefined){$(".sp-content-up .tab").append("<div class='tabtitle'>" + this.innerHTML + "</div>");}});$(".sp-content-up .ms-webpart-chrome-title").hide(); $(".sp-content-up .ms-webpartzone-cell:eq(0)").addClass("tabcontentshow");            $(".tabtitle:eq(0)").addClass("tabtitleclick");            $(".tabtitle").on("click", function () {                var otherTitle = $(".tabtitle:not(.tabtitle:eq('" + $(this).index() + "'))");                var otherContent = $(".sp-content-up .ms-webpartzone-cell:not(.sp-content-up .ms-webpartzone-cell:eq('" + $(this).index() + "'))");                $(".sp-content-up .ms-webpartzone-cell:eq('" + $(this).index() + "')").addClass("tabcontentshow");                $(this).addClass("tabtitleclick");                otherContent.removeClass("tabcontentshow");                otherTitle.removeClass("tabtitleclick");            });});</script>

 

<style>    .sp-content-up  .tabtitle{font-size:13px !important;}        .tabtitle{            float: left;           margin-right:2px;            width: 200px;            height:30px;            background-color: rgb(230, 230, 230);            color: black;            text-align:center;            cursor:pointer;            border-width:1px;          border-color: gray;          border-style: solid;        }                .tabtitleclick {            background-color:white;       border-bottom-color: white;        }                         .tabtitle:hover {            background-color: rgb(241, 241, 241);        }                        .clear {                clear: both;            }        .sp-content-up .ms-webpartzone-cell {            display: none;        }        .sp-content-up   .tabcontentshow {            display: block;            color: white;        } </style>



 

5. check the result, is that cool!?

Tab with web parts in Sharepoint 2013

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.