我在下一页上有一个充满数据的JSON Feed:
'./PlanningFeed.xhtml'
我可以在基本用法fullcalendar上显示数据并且它正在运行。
问题是我想只显示符合条件的事件。
这就是我获取JSON数据的方式:
eventSources: [
{
url: './PlanningFeed.xhtml',
type: 'GET',
data: {
start: firstdate,
end: lastdate,
salle: salle //this is my attempt to get only events that has a specific
//"salle" attribute,the field salle is declared and populated
//in all event objects.
//but this parameter here it doesn't affect
//anything and my calendar is created with all salle events showed.
//which means this doesn't work.
}
}
]
});
我也尝试了eventRender
,但无济于事:
eventRender: function(event, element) {
if (event.salle === salle) {
console.log('added', event.salle);
} else if (event.salle !== salle) {
console.log('deleted', event.salle);
$(placeholder).fullCalendar('removeEvents', event.id);
}
}
我不想删除JSON提要中的数据,以后可能会使用它。我希望我能查询JSON提要只显示我想要的事件(例如:event.salle ='XYZ')。
请不要犹豫,询问更多信息。
更新1:
[{"title":"uiyuiyutyiyuity\nANGIO SCANNER RENALE.","start":"2014-12-01T07:30:00","end":"2014-12-01T07:45:00","salle":"SCANNER1","backgroundColor":"#B6E8FF","patState":4,"rapportWrittenState":0,"patientFullName":"uiyuiyutyiyuity","studyDureeMinute":15,"payStateImage":"non-cote","bannerColor":"#98d1ec","borderColor":"#98d1ec","id":"1"},
{"title":"hjghjghjghj\n2 CHEVILLE F","start":"2014-12-01T07:15:00","end":"2014-12-01T07:35:00","salle":"RADIO 1","backgroundColor":"#CDDFED","patState":1,"rapportWrittenState":0,"patientFullName":"hjghjghjghj","studyDureeMinute":20,"payStateImage":"non-cote","bannerColor":"#a0c2dc","borderColor":"#a0c2dc","id":"2"},
{"title":"yiyuiyuiyui\nANGIO SCANNER ABDOMINALE.","start":"2014-12-01T06:55:00","end":"2014-12-01T07:15:00","salle":"SCANNER1","backgroundColor":"#F0F0F0","patState":7,"rapportWrittenState":0,"patientFullName":"yiyuiyuiyui","studyDureeMinute":20,"payStateImage":"non-cote","bannerColor":"#C8C8C8","borderColor":"#C8C8C8","id":"3"},
{"title":"tuutyuj\nANGIO SCANNER CEREBRAL.","start":"2014-12-01T06:25:00","end":"2014-12-01T06:45:00","salle":"SCANNER1","backgroundColor":"#E8F5BB","patState":5,"rapportWrittenState":0,"patientFullName":"tuutyuj","studyDureeMinute":20,"payStateImage":"non-cote","bannerColor":"#cede97","borderColor":"#cede97","id":"4"},
{"title":"dfgdfgdfgdfg\nANGIO SCANNER CERVICAL.","start":"2014-12-01T06:00:00","end":"2014-12-01T06:20:00","salle":"SCANNER1","backgroundColor":"#FFC592","patState":3,"rapportWrittenState":0,"patientFullName":"dfgdfgdfgdfg","studyDureeMinute":20,"payStateImage":"c_valider","bannerColor":"#e8a66c","borderColor":"#e8a66c","id":"5"}]
答案 0 :(得分:1)
我在完整日历中表现不佳,但我找到了解决问题的方法
删除事件后,您必须重新呈现所有事件:
$(placeholder).fullCalendar('removeEvents', event.id);
setTimeout(function(){
$(placeholder).fullCalendar("rerenderEvents");
},1);
我确实使用超时。它正在测试fullcalendar-2.2.3新下载。
编辑: 确保您的变量和条件。
答案 1 :(得分:0)
var eventStore;// store pre filtered events here so we can get at them later
...
events: function(start,end,callback) {
$.ajax('http://www.myendpoint.com/getevents.php', {start:start,end:end}, function(data) {
var events = JSON.parse(data);
eventStore = events;
var newEventList = [];
for(var i = 0; i < events.length; i++){
if(events.salle == true){
newEventList.push(events[i]);
}
}
callback(newEventList);
});
}
让web服务过滤数据并返回所需内容可能是最有意义的,但您可以使用上面的自定义函数在显示之前过滤事件。
答案 2 :(得分:0)
通过使用ajax oncomplete从服务器端调用fullcalendar完成,因为我使用JSF。
希望这有帮助。