【发布时间】:2015-01-31 23:24:11
【问题描述】:
我在以下页面上有一个包含完整数据的 JSON 提要:
'./PlanningFeed.xhtml'
我可以在基本使用情况完整日历上显示数据并且它正在工作。
问题是我只想显示满足条件的事件。
这就是我获取 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"}]
【问题讨论】:
-
你能展示你的json返回的示例代码吗?
-
不是要求完整的日历来触发 ajax,你不能只发送请求、获取数据、过滤数据、将其保存在数组中并将其作为完整日历的输入吗?
-
因为我需要在同一页面中创建 5 个 fullcalendra 实例,并且每个人都需要显示来自同一个 JSON 提要的特定事件,我如何明确告诉他们每个人要获取/显示哪些数据.
-
我不确定
$(placeholder).fullCalendar('removeEvents', event.id);是否有效。我也对事件使用这种语法:events: { url: 'path/events.php', }现在我正在测试你的情况。 -
我可以显示我对此没有任何问题的事件,我的问题是我如何才能从充满事件的 JSON 提要中仅显示特定的满足条件事件(换句话说,我有一个 JSON一天内所有 5 个房间的饲料,我希望每个日历都显示一个房间的事件,如何实现?)
标签: javascript jquery json jsf-2 fullcalendar