Page 1 of 1

[REACT] Sort events in week view

Posted: Tue May 30, 2023 6:20 pm
by vconstruct

Hi team

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


Re: [REACT] Sort events in week view

Posted: Tue May 30, 2023 6:37 pm
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


Re: [REACT] Sort events in week view

Posted: Tue May 30, 2023 8:27 pm
by Animal

In what way?

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


Re: [REACT] Sort events in week view

Posted: Wed May 31, 2023 8:38 am
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;
            }
          }
        },
          

Re: [REACT] Sort events in week view

Posted: Thu Jun 01, 2023 5:35 pm
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?


Re: [REACT] Sort events in week view

Posted: Thu Jun 01, 2023 6:06 pm
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 693 times

Re: [REACT] Sort events in week view

Posted: Fri Jun 02, 2023 3:16 pm
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


Re: [REACT] Sort events in week view

Posted: Fri Jun 02, 2023 3:28 pm
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 673 times

Re: [REACT] Sort events in week view

Posted: Fri Jun 02, 2023 3:30 pm
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?