我在尝试在 FullCalendar 上显示事件时遇到问题。有些事件会显示,有些则不会。
我通过JSON填充 FC ,到目前为止,即使分页仅检索所选月份的事件,它也能正常工作。
...
events: {
url: '/getEvents',
method: 'GET',
failure: function(error) {
console.log(error);
alerta("Error", "Ups...", "red");
},
},
...
但是现在我正在尝试从存储在数据库中的其他内容中添加更多事件,尽管以相同的方式构建它们,但它们并未显示在日历上。
我构建这样的事件(我已经清理了代码):
rows = connection.execute("SELECT...........")
events = []
for row in rows:
event = {"id": row['id'], "title": row['title'], "start": row['start'], "end": row['end'], "allDay": row['allDay'], "url": row['url'], "color": row['color'], "extendedProps": {"company": row['company'], "state": fila['state']}}
if row['groupId'] is not None:
event['groupId'] = str(row['groupId'])
events.append(event)
现在,在程序的其他部分,我以类似的方式创建事件:
more_rows = connection.execute("SELECT....")
more_events = []
for row in more_rows:
event = {"id": row['id'], "title": row['title'], "start": row['start'], "end": row['end'], "allDay": 1, "url": "", "color": row['color'], "extendedProps": {"company": row['company'], "description": row['description'], "type": row['type'], "tecnology": row['tecnology'], "state": row['state']}}
more_events.append(event)
它们一起发送到浏览器:
...
events.extend(more_events)
return jsonify(events), 200
...
将jsonify(events)这个 JSON 发送到浏览器(我在 python 代码上使用双引号,但 jsonify 将其替换为单引号):
[{'allDay': 1, 'color': 'blue', 'end': '2019-10-24T00:00:00.000Z', 'extendedProps': {'company': 'Company test', 'state': 'Active'}, 'groupId': '48', 'id': 27, 'start': '2019-10-23T00:00:00.000Z', 'title': 'A title', 'url': ''},
{'allDay': 1, 'color': 'blue', 'end': '2019-10-11T00:00:00.00.000Z', 'extendedProps': {'company': 'Company test', 'description': 'oapisdvañklsjdhalksjdflaksjdf', 'state': 'Active', 'tecnology': 'javascript+html', 'type': 'Cool'}, 'id': 74, 'start': '2019-10-07T00:00:00.00.000Z', 'title': 'owqsakjdflh', 'url': ''},
问题是......它作为事件打印的第一个元素,但 JSON 上的其余元素没有打印。
我看不出我的错误在哪里或我做错了什么。
呼啦一阵风
相关分类