Sort events

Hi:

How can I sort events?

For example: in the list view and month view I want the Highest priority events to show at the top of the day, even though they may be scheduled for a later time. In the day view the sort order wouldn’t change.

I guess this could get a little tricky, but the sort would need to be something like this:
Day, Priority, Time

2012,0, 16:00
2012,1, 08:00

In the this case a 0 priority is higher than a 1 priority. So even though even though the first event is later in the day, it shows at the top of the list.

Also I would hope that any approach would not require a refetch of the data. The same list, just sorted differently based on view type.

Thanks for you help and ideas

Jim

JIm

You may try to use the following approach

$$(“scheduler”).$$(“list”).attachEvent(“onBeforeRender”,listSort);
$$(“scheduler”).$$(“dayList”).attachEvent(“onBeforeRender”,listSort);

function listSort(){
this.data.blockEvent();
this.data.order = dhx.toArray(this.data.order)
this.data.sort(function(event1,event2){
if(…){
/in this case event1 will be display before event2/
return 1
}
return -1;

  });
  this.data.unblockEvent();

}
Please see details about sorting:

docs.dhtmlx.com/touch/doku.php?i … rt#details

The default sorting is:

this.data.sort(function(event1,event2){
return event1.start_date < event2.start_date?1:-1;
});