2017-07-25 132 views
0

嗨我想通过在页面中插入三个日历webparts并通过在CEWP中插入下面的代码来开发三个月滚动日历视图。SharePoint 2010滚动三个月日历

日历应分别滚动到上一个或下一个,但单击按钮'PrevMonth'和'NextMonth'。

它似乎只是滚动的工作,但有些事情是错误的。有人可以帮我弄这个吗 ?

< script type = "text/javascript" > 
 
    $(document).ready(function() { 
 
    window.setTimeout(setCal, 1000); 
 

 
    }); 
 

 
var CurrentDate = new Date(); 
 

 

 
function setCal() { 
 
    $("#PrevMonth").click(PrevMonth); 
 
    $("#NextMonth").click(NextMonth); 
 

 
    MoveToDate((CurrentDate.getMonth() + 2).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3'); 
 
    MoveToDate((CurrentDate.getMonth() + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2'); 
 
    MoveToDate((CurrentDate.getMonth()).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1'); 
 
} 
 

 
function PrevMonth() { 
 
    MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3'); 
 
    MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2'); 
 
    MoveToDate((CurrentDate.getMonth() - 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1'); 
 
} 
 

 
function NextMonth() { 
 
    MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ3'); 
 
    MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ2'); 
 
    MoveToDate((currentMonth + 1).toString() + '\u002f' + CurrentDate.getDate().toString() + '\u002f' + CurrentDate.getFullYear().toString(), 'WPQ1'); 
 
} 
 

 
< 
 
/script>

回答

0

在这里你去,经过多次搜索,这个完美的作品。

<script type="text/javascript" src="http://sharepoint server/sites/page/Scripts/jquery.SPServices.js"></script> 
    <script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script> 
    <script type="text/javascript"> 

    function myPrevFunction() { 
     document.getElementById("WPQ3_nav_prev_img").click(); 
     document.getElementById("WPQ4_nav_prev_img").click(); 
     document.getElementById("WPQ5_nav_prev_img").click(); 
     document.getElementById("WPQ6_nav_prev_img").click(); 
     document.getElementById("WPQ7_nav_prev_img").click(); 
     document.getElementById("WPQ8_nav_prev_img").click(); 
    } 

    function myNextFunction() { 
     document.getElementById("WPQ3_nav_next_img").click(); 
     document.getElementById("WPQ4_nav_next_img").click(); 
     document.getElementById("WPQ5_nav_next_img").click(); 
     document.getElementById("WPQ6_nav_next_img").click();  
     document.getElementById("WPQ7_nav_next_img").click(); 
     document.getElementById("WPQ8_nav_next_img").click(); 
    } 



    </script> 
    <input type="button" id="CFCCalPrev" value="Prev" onclick="myPrevFunction()"> 
    <input type="button" id="CFCCalNext" value="Next" onclick="myNextFunction()">