[REACT] Sort events in week view
Hi team
Can we sort events in the week view based on the event name
Hi team
Can we sort events in the week view based on the event name
Hey vconstruct,
Yes, you'll probably need to listen to the view change (to identify when the week view is being set) https://bryntum.com/products/calendar/docs/api/Calendar/view/Calendar#event-activeItemChange
And inside of that, you can add a sort to the eventStore https://bryntum.com/products/calendar/docs/api/Scheduler/data/EventStore#function-sort
And if you don't want to keep the sort on other views, you can use the activeItemChange event listener to remove the sort using https://bryntum.com/products/calendar/docs/api/Scheduler/data/EventStore#function-clearSorters
In what way?
They are displayed in order of start date as you can see.
We want the events to be sorted based on name instead of start date.
eventSorter function in modeDefaults worked for month view but its not sorting for week view
modeDefaults : {
eventSorter(a:any,b:any) {
a = a.data.name
b = b.data.name
if(a < b){
return -1;
}else if(a > b){
return 1;
}else{
return 0;
}
}
},
but its not sorting for week view
How do you expect to sort events in a different way on a timeline if not by date? Could you please clarify what exactly do you expect to see in Week view with sorting?
Do you just need a CalendarRow
as a mode like this?
The above almost works. It is short of just a few tweaks. But it should of course fully work.
Here's a ticket to make it work: https://github.com/bryntum/support/issues/6913
Of course a multi day event will poke out into future cells, so might be out of order in those cells.
But there's nothing we can do about that. You see "Hackathon" is correctly sorted into second position in name order in the first cell. But a multi day event is a continuous bar, so future cells have to sort themselves around that fixed part.
I'm spending a lot of time trying to guess what you need and fix it all. Is this in fact what you need?