jQuery FullCalendar event sorting

前端 未结 5 1177
南方客
南方客 2020-12-16 05:24

I have numerous events that are all day events, and all start at the same time. I create the events in the order I would like them to appear on the full calendar view, but t

5条回答
  •  感动是毒
    2020-12-16 05:40

    I found that chrome respects the start time. When building the event, I simply add a second to each item in the list. In the example, I have a resultset with each of the values for the specific date in columns. Start is in column 0, and title is in column 1 in the resultset.

    In my example, I do the following:

    var startVal = "";
    $.each(data.ResultSet, function(row)
    title = data.ResultSet[row][1];
    startVal = new Date(data.ResultSet[row][0]);
    startVal.setSeconds(startVal.getSeconds() + row);
    start: startVal;
    

    ...

    This way I have the title displayed in the order I put then into the event object.

    In your data example, I would make the following change:

    var events=[
    {id:1, title:'Supervisor',start:'2011-11-05T00:00:01-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:2, title:'Tech2',start:'2011-11-05T00:00:02-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:3, title:'Tech2',start:'2011-11-05T00:00:03-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:4, title:'Tech1',start:'2011-11-05T00:00:04-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:5, title:'Tech1',start:'2011-11-05T00:00:05-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:6, title:'Tech1',start:'2011-11-05T00:00:06-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:7, title:'Supervisor',start:'2011-11-06T00:00:07-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:8, title:'Tech2',start:'2011-11-06T00:00:08-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:9, title:'Tech2',start:'2011-11-06T00:00:09-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:10, title:'Tech1',start:'2011-11-06T00:00:10-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:11, title:'Tech1',start:'2011-11-06T00:00:11-05:00',st_hours:10,ot_hours:0,allDay:true},
    {id:12, title:'Tech1',start:'2011-11-06T00:00:12-05:00',st_hours:10,ot_hours:0,allDay:true}];
    

    Hope this helps!

    Ken

提交回复
热议问题