Our powerful JS Calendar component


Post by vconstruct »

Hi team

Can we sort events in the week view based on the event name


Post by marcio »

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

Best regards,
Márcio


Post by Animal »

In what way?

They are displayed in order of start date as you can see.


Post by vconstruct »

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;
            }
          }
        },
          

Post by alex.l »

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?

All the best,
Alex


Post by Animal »

Do you just need a CalendarRow as a mode like this?

Screenshot 2023-06-01 at 18.05.21.png
Screenshot 2023-06-01 at 18.05.21.png (147.77 KiB) Viewed 383 times

Post by Animal »

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


Post by Animal »

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.

Screenshot 2023-06-02 at 15.26.18.png
Screenshot 2023-06-02 at 15.26.18.png (85.87 KiB) Viewed 363 times

Post by Animal »

I'm spending a lot of time trying to guess what you need and fix it all. Is this in fact what you need?


Post Reply