0

我有一个包含开始日期和结束日期的列表。我正在使用 JQuery AJAX 检索它。现在如何在 FullCalendar 中将该日期显示为事件。

从列表中检索数据的代码

   var soapEnv =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
            <soapenv:Body> \
                 <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                    <listName>BatchSchedule</listName> \
                    <viewFields> \
                        <ViewFields> \
                           <FieldRef Name='BatchId' /> \
                           <FieldRef Name='StartDt' /> \
                           <FieldRef Name='Enddt' /> \
                           <FieldRef Name='location' /> \
                        </ViewFields> \
                    </viewFields> \
                     <rowLimit>8500</rowLimit>\
                </GetListItems> \
            </soapenv:Body> \
        </soapenv:Envelope>";

    $.ajax({
        url: "https://www.mysite.com/sites/Batch/_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: "text/xml; charset=\"utf-8\""
    }); // end ajax function

  function processResult(xData, status) 
  {
     $(xData.responseXML).find("z\\:row").each(function() {});
  }

我昨天写的完整代码但没有得到想要的结果

    function getbatchdetails(loc){ //loc - passing location as parameter
var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>batch</listName> \
                        <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='BatchId' /> \
                               <FieldRef Name='StartDt' /> \
                               <FieldRef Name='Enddt' /> \
                               <FieldRef Name='location' /> \
                               <FieldRef Name='ID' /> \
                            </ViewFields> \
                        </viewFields> \
                         <rowLimit>500</rowLimit>\
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";

        $.ajax({
            url: "https://www.mysite.com/sites/Batch/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        }); // end ajax function
        function processResult(xData, status) 
        {
            $(xData.responseXML).find("z\\:row").each(function() { 
            var returnedloc = new String($(this).attr("ows_location"));
            if(loc==returnedloc){
                newEvent[0]=new String($(this).attr("ows_Title"));
                newEvent[1]=$(this).attr("ows_StartDt");
                newEvent[2]=$(this).attr("ows_Enddt");
                eventsArray.push(newEvent);
              }
            });//responseXML
        var nextEvent = [];
        for (var k=0;k<eventsArray.length;k++){
            nextEvent.push ({
                title: eventsArray[k][0],
                start: eventsArray[k][1],
                end: eventsArray[k][2],
                allDay: false
            });
        }
        $('#calendar').fullCalendar({
            /*defaultView: 'year',
            year: 2012,
            header: {
                left: 'prev,next today',
                center: 'title',
                //right: 'year,month,agendaWeek,agendaDay'
                right: 'year,month'
            },*/
            editable: true,
            events: nextEvent,
            colour: 'blue'
        });       }//processResult
}//end of getBatch Details
4

1 回答 1

1

你可以试试这个:

$("#calendar").fullCalendar('renderEvent',
{
    title: "some title",
    start: eventStart,
    end: eventEnd,
    allDay: allDay
},
true // make the event "stick"

);

请记住,您需要在代码中拥有eventStarteventEnd作为 JS 变量(您可以随意调用这些变量)。

于 2012-12-27T13:02:29.163 回答