Our powerful JS Calendar component


Post by longevo-florian »

Hi,

in my implementation I am loading resources dynamically, and adding them to the Calendar by binding to the resources property of the calendar.

I receive those resources in a specific order from our server, but when I try to add them to the calendar, they get sorted differently again. Is there any way to disable this automatic resource sorting, so that the order I receive from our server is taken into the calendar?


Post by saki »

Actually, the resources are not sorted in the resourceStore but they only appear sorted in the sidebar. Sidebar's item resourceFilter uses a chained store and that is sorted by name by default.

To turn it off, add the following to your calendar config:

    sidebar : {
        items : {
            resourceFilter : {
                store : {
                    sorters : []
                }
            }
        }
    },

Post by longevo-florian »

Hi,

first of all - thanks, that works for the resourceFilter. Is there something similar for the resource view? Because this change only makes the resourceFilter list not sort, but the resourceView is still being sorted.

Also, there seems to be some kind of caching in place in the resourceView. Is it possible to turn that off as well? Because it produces a behavior where the order of the list that is being fed into the calendar changes, but the resourceView still displays the resources in the old order.


Post by saki »

Records from the resourceStore are directly used for resourceView(s) in the order in which they are stored in the resourceStore and that is the order in which they are received from the server. For example, https://bryntum.com/examples/calendar/resourceview/ shows John Adams before Jenny Brown because he comes first in the json file.

If it is sorted in your case, you can verify the value of bryntum.query('calendar').resourceStore.sorters – it should be an empty array for a not-sorted store.

However, there is one bug related to it here: https://github.com/bryntum/support/issues/3739 Changing the sorting does not reflect in the view.

If you see your resourceStore sorted, and it shouldn't, post please a runnable code so that we can investigate the cause of it.


Post by Animal »

The order that the subviews are in can become out of sync with the order in the resource store if the resource store is being filtered.

So if you filter in resources A, C, and E initially, the resourceview will show A, C and E

If then you remove the filtering and resources B and D are now needed, it will add them, so will show A, C, E, B, D

We will need to somehow programatically make the order of the views just "match" the order that the resource store has. Our _items collection needs a sorter added to it with as custom comparator function which compares the indexOf the two resources in the main resource store.

And this will have to be re-run at the start of a refresh so that our items are always in the same order as the resource store.


Post by longevo-florian »

Hi Animal,

the behavior you're describing is exactly what I want it to do, and it also works when i select new resources. However, when I have my Resources selected in an Order of A, C, E, B, D, and i deselect E for an example and then re-select it, instead of showing A, C, B, D, E, it shows A, C, E, B, D again. The list I feed into the angular component however is in the order I would expect it (A, C, B, D, E). So it appears the resource view "remembers" that E has already been selected before and re-inserts it at the previous position. That is behavior I would like to stop from happening

Thats what I meant by saying there has to be some sort of caching in place before. Can I disable that in any way?


Post by Animal »

We'll have to programatically resync the order as I described above after any change to the resourceStore.

Here's the ticket to track: https://github.com/bryntum/support/issues/3769


Post by longevo-florian »

Hi Animal, is there any update about the status of ticket 3769? This is a really critical bug to us and blocks the whole planning in the resource view. Would it be possible to drop it in the next update? Thanks in advance.


Post by mats »

We will try to fix that ticket during this week!


Post by longevo-florian »

That would be AMAZING, thanks!


Post Reply