[Resolvido] fullCalendar não exibe eventos retornados em Json
Pessoal estou tentando exibir os eventos no meu calendário, porém não estou tendo sucesso. Sou iniciante em Jquery e após pesquisar em vários sites e consultar vários exemplos não consegui exibir os eventos. O calendário é exibido, os eventos não!
Minha controller (ASP MVC):
var listCalender = new List<object>();
var dal = new DAL.PosVendasParticipantesDAL();
var calender = dal.Todos();
if (calender.Rows.Count > 0)
{
foreach (DataRow dr in calender.Rows)
{
var entity = new Modelos.PosVendasParticipantesModelo();
entity.ID = Convert.ToInt32(dr["ID"]);
entity.ProximaLigacao = Convert.ToDateTime(dr["PROXIMA_LIGACAO"]);
listCalender.Add(new
{
title = entity.ID,
start = entity.ProximaLigacao,
});
}
}
return Json(listCalender, JsonRequestBehavior.AllowGet);
Após o retorno Json, obtenho os seguintes dados:
[{"title":1,"start":"\/Date(1469725020000)\/"},{"title":2,"start":"\/Date(1469725020000)\/"},{"title":3,"start":"\/Date(1470674040000)\/"}
É exatamente os parâmetros que o fullCalendar exige pra exibir eventos, acho que estou sabendo interpretar o Json retornado!
Jquery:
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '2018-03-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: $(function (start, end, timezone, callback) {
$.ajax({
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Home/GetEvents",
success: function (dados) {
alert('foi');
$(dados).each(function (i) {
//document.writeln("<p>ID: " + dados[i].id + " | Data: " + dados[i].Start + "</p>")
events.push({
title: $(this).attr('title'),
start: $(this).attr('start')
});
});
}
});
})
});
});
</script>Discussão (4)
Carregando comentários...