[英]How to call custom properties or fields for event in FullCalendar?
I would like to know, how can I get other components (ID, title, start and end) in FullCalenda.我想知道,如何在 FullCalenda 中获取其他组件(ID、标题、开始和结束)。
I have a table, in a database, that have a lot of fields like status, responsible, departament, and I do a select in the table who give me a JSON of PHP for the FullCalendar.我在数据库中有一个表,它有很多字段,如状态、负责、部门,我在表中做了一个选择,它为我提供了 FullCalendar 的 PHP JSON。 In the FullCalendar I can get the standards attributes of the Full Calendar that are id, title , start and end.
在 FullCalendar 中,我可以获得完整日历的标准属性,即 id、title、start 和 end。
How can I get other result attributes on the database selection (fields like status, responsible, departament) ?如何获取数据库选择的其他结果属性(状态、责任、部门等字段)?
The array below, is the result of my select.下面的数组是我选择的结果。
Below you can see the code where I receive the data in the FullCalendar:您可以在下面看到我在 FullCalendar 中接收数据的代码:
eventClick: function(info) { //O parâmetro 'info' é que contém os valores que vem do retorno da consulta do banco de dados info.jsEvent.preventDefault(); //Passando valores para os elementos HTML $('#visualizar #mostrar-titulo').text(info.event.title); $('#visualizar #mostrar-inicio').text(info.event.start.toLocaleString()); $('#visualizar #mostrar-fim').text(info.event.start.toLocaleString()); $('#visualizar #mostrar-status').text(info.event.STATUS); //Exibe o modal (quando clicamos no respectivo evento) que mostra as informações resultantes da consulta no banco de dados. $('#visualizar').modal('show'); },
Code HTML代码 HTML
<div class="modal fade" id="visualizar" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Detalhes do Eventos</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Fechar"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <!-- <div class="visevent">--> <dl class="row"> <dt class="col-lg-3">Título do evento</dt> <dd class="col-lg-9" id="mostrar-titulo"></dd> <dt class="col-lg-3">Status do Evento</dt> <dd class="col-lg-9" id="mostrar-status"></dd> <dt class="col-lg-3">Início do evento</dt> <dd class="col-lg-9" id="mostrar-inicio"></dd> <dt class="col-lg-3">Fim do evento</dt> <dd class="col-lg-9" id="mostrar-fim"></dd> </dl> <!-- </div>--> </div> </div> </div> </div>
Watch how I show the modal (when we click in the respective event).观看我如何显示模态(当我们在相应的事件中单击时)。
You may try to use "extendedProps" option for an event object to access non-standard field as follow:您可以尝试对事件对象使用“extendedProps”选项来访问非标准字段,如下所示:
eventClick: function(info) {
info.jsEvent.preventDefault();
//Passando valores para os elementos HTML
$('#visualizar #mostrar-titulo').text(info.event.title);
$('#visualizar #mostrar-inicio').text(info.event.start.toLocaleString());
$('#visualizar #mostrar-fim').text(info.event.start.toLocaleString());
$('#visualizar #mostrar-status').text(info.event.extendedProps.STATUS);
$('#visualizar').modal('show');
}
I haven't tried your code, but I used my own fields like this.我没有试过你的代码,但我使用了我自己的字段。
Please be aware about version changes and using options in FullCalendar, as mentioned about extendedProperties in this post:请注意 FullCalendar 中的版本更改和使用选项,如本文中关于 extendedProperties 所述:
https://github.com/fullcalendar/fullcalendar/issues/4652 https://github.com/fullcalendar/fullcalendar/issues/4652
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.