Our powerful JS Calendar component


Post by lanpeng »

Hi bryntum team.
I am using calendar version 4.3.3. In resourceview mode, there is an exception. add data to resourcefilter through “this.calendar.widgetMap.resourceFilter.selected.add(this.resourceGroup)” . When i select some items in resourcefilter , the selected items are not displayed in the calendar component on the right.

Attachments
屏幕截图 2022-03-24 175508.png
屏幕截图 2022-03-24 175508.png (71.32 KiB) Viewed 673 times

Post by Animal »

As an experiment, see if this works:

const { resourceFilter } = this.calendar.widgetMap;

resourceFilter.selected.add(resourceFilter.store.getById(this.resourceGroup.id));

Post by lanpeng »

Hi Animal,
this.resourceGroup is an Array . resourceFilter.selected.add(resourceFilter.store.getById(this.resourceGroup.id)) will report error "Cannot read properties of undefined (reading 'id')"


Post by Animal »

The resourceStore does actually contain these resources you are selecting?


Post by Animal »

I just tried it in the example here.

Deselected all the resources. Then added them directly to the selected Collection.

rf.selected.add([calendar.resourceStore.getAt(0), calendar.resourceStore.getAt(1)])

You can see that it works.

Of course the resources have to actually be in the resourceStore

selectusingarray.gif
selectusingarray.gif (114.87 KiB) Viewed 670 times

Post by lanpeng »

Hi Animal ,
I'm sure that resources already exists in resourceStore before I execute the method this.calendar.widgetMap.resourceFilter.selected.add(this.resourceGroup)” .In fact, this.resourceGroup Is a variable .
The first time it was used as resourceStore.data, it was ok. However, assign it a new value.the problem I stated above happened.When I uncheck any one item of the resourcefilter,and then I selected it again .the resources displayed.
As shown the picture, i toggle selected the "Du,Zhuo" ,and the resources show in calendar.

Attachments
屏幕截图 2022-03-24 175543.png
屏幕截图 2022-03-24 175543.png (76.68 KiB) Viewed 666 times

Post by Animal »

I don't really understand what you are doing at all.

If you use it as data, then it won't be records. It will be data.

You have to select records. You have to add a record that exists in the resourceStore to the selected Collection.

That will work.

You must be doing something different. If it throws an error, set the debugger to break on errors, then take a look around when it stops.


Post by Animal »

And if you add, as a selected item, a raw data object with an ID, then that will displace any real ResourceRecord in the Collection with the same ID. That's how collections work


Post by Animal »

I think we need a simpler way of selecting in the List class. Here's a ticket: https://github.com/bryntum/support/issues/4404


Post by Animal »

I have added a new API to the List class. select and deselect methods.

You can pass an array or a single param.

The thing you pass may be an id (eg number or string), or it may be a thing which contains an id property.

It will select or deselect the passed IDs. Sound Good?

selectAPI.gif
selectAPI.gif (408.9 KiB) Viewed 661 times

Post Reply