我的列表具有开始日期和结束日期。我正在检索使用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
您可以尝试以下方法:
$("#calendar").fullCalendar('renderEvent',
{
title: "some title",
start: eventStart,
end: eventEnd,
allDay: allDay
},
true // make the event "stick"
);
请记住,您需要将eventStart
和eventEnd
作为代码中的JS变量(无论如何您都可以调用所需的这些变量)。