jquery - Full calendar not ordering the events in correct order -
i using full calendar plugin. want events ordering according start date/time ascending. can see below event # 2, event # 3 & event # 4 in correct order event # 1 not in correct order. should in last.
wrong order:
[ {"id":"1","title":"aaa","start":"2013-04-01 00:00:00","end":"2013-04-01 23:59:59", "allday":false}, {"id":"2","title":"bbb","start":"2013-04-01 07:30:00","end":"2013-04-01 09:30:00", "allday":false}, {"id":"3","title":"ccc","start":"2013-04-01 08:00:00","end":"2013-04-01 10:30:00", "allday":false}, {"id":"4","title":"ddd","start":"2013-04-01 13:00:00","end":"2013-04-01 10:30:00", "allday":false}, ] how wanted (order time asc):
[ {"id":"2","title":"bbb","start":"2013-04-01 07:30:00","end":"2013-04-01 09:30:00", "allday":false}, {"id":"3","title":"ccc","start":"2013-04-01 08:00:00","end":"2013-04-01 10:30:00", "allday":false}, {"id":"4","title":"ddd","start":"2013-04-01 13:00:00","end":"2013-04-01 10:30:00", "allday":false}, {"id":"1","title":"aaa","start":"2013-04-01 23:00:00","end":"2013-04-01 23:59:59", "allday":false} ] it looks perfect in week view & day view not ordering in month view. events coming database , passing json feed fullcalendar render events. in regard highly appreciated.
you can use underscore.js sort object array.
var events = [ {"id":"1","title":"aaa","start":"2013-04-01 23:00:00","end":"2013-04-01 23:59:59", "allday":false}, {"id":"2","title":"bbb","start":"2013-04-01 07:30:00","end":"2013-04-01 09:30:00", "allday":false}, {"id":"3","title":"ccc","start":"2013-04-01 08:00:00","end":"2013-04-01 10:30:00", "allday":false}, {"id":"4","title":"ddd","start":"2013-04-01 13:00:00","end":"2013-04-01 10:30:00", "allday":false} ]; var sortedevents = _.sortby(events, function(data){ return data.start; });
Comments
Post a Comment