I am loading in the events using Connector and would like to secondarily sort the events by their id if their dates are the same. I have tried doing an ORDER BY id ASC in the SQL query but no luck. It seems this will have to be fixed in javascript.
I really hope there is a solution as in its current state there is absolutely NO consistency which is bad for the user experience.
$scheduler->render_sql(“SELECT id,datestart,dateend,timestart,timeend ORDER BY id ASC”, “id”, “datestart, dateend, title”);[/code]
As you can see I am ordering the output of the events using the ORDER BY in MySQL. When I view the output my events do not change order so it is the monthly view of the calendar doing it.
Indeed sorting events on server side won’t help anything (except their order in xml file) as later on they will be re-sorted to be displayed on any view.
For the month view, for example, following logic is used:
scheduler._time_order=function(evs){
evs.sort(function(a,b){
if (a.start_date.valueOf()==b.start_date.valueOf()){
if (a._timed && !b._timed) return 1;
if (!a._timed && b._timed) return -1;
return a.id>b.id?1:-1;
}
return a.start_date>b.start_date?1:-1;
});
}; a._timed is a flag if event is held for several days (should be displayed as bar).
As you see there is need for events’ ids only in case there their start dates are the same and we are actually using this check.
If I understood correctly in your case there is no consistency in how events are displayed: one or another event can be displayed as first. If you can narrow down it to some events then please provide events properties (their start date, end date, ids).
Make sure that somehow events’ start date is not modified every time you refresh scheduler.
Older versions of scheduler (2.2 and below) can have such issue. They using a bit more simpler sorting logic, but in latest version sorting order is consistent for sure.