Secondary sorting of events

Hello,

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.

Thanks,

Tim

Hello,

On what view do you experience this issue?
Can you please attach screenshot with events’ data?

Best regards,
Ilya

Hello,

I am experiencing this on the monthly view.

I am not sure what you mean by my event data. I am using my database to generate the events using the following code.

[code]function my_code($action){
$ds = $action->get_value(“datestart”);
$ts = $action->get_value(“timestart”);
$de = $action->get_value(“dateend”);
$te = $action->get_value(“timeend”);

$action->set_value("datestart", $ds." ".$ts);
$action->set_value("dateend", $de." ".$te);
}
	
$scheduler->event->attach("beforeRender", "my_code");

$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.

I am loading the events using connector:

[code] scheduler.init(‘scheduler_here’,null,“timeline”);
scheduler.load("/calendar/get_data");

	var dp = new dataProcessor("/calendar/get_data");[/code]

I hope this helps and that there is a solution.

Tim

Hello, Tim.

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.

Best regards,
Ilya

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.

Hello,

I am using 2.3 and was having the issue. The code posted above seems to have resolved the issue.

Thank-you,

Tim