Our powerful JS Calendar component


Post by orthobridge »

I'm trying to set the selected values for the resourceFilter, it does set as i can log it in the console but only one resource is checked in the resources in the sidebar

beforeResponseApply({source, requestType, response}) {
                console.log(response.all_practice_chairs)
                const {resourceFilter, showUnassigned } = calendar.widgetMap;
                //before
                console.log(resourceFilter.selected._values)
                //set selected resources
                resourceFilter.selected._values = getResourceId(response.all_practice_chairs, "practise_room_chair_id")
                //after
                console.log(resourceFilter.selected._values)
                console.log(getResourceId(response.all_practice_chairs, "practise_room_chair_id"))
                }

thats my code above, the log after the //after comment displays the arrays but only one resource is checked in the resources in the sidebar


Post by Animal »

You can't go behind the scenes and set _values property of the selected Collection. That is a private property, and changing it will break the class.

You can either use the List methods https://bryntum.com/products/calendar/docs/api/Core/widget/List#function-deselectAll then https://bryntum.com/products/calendar/docs/api/Core/widget/List#function-select

Or, change the Collection in one step using https://bryntum.com/products/calendar/docs/api/Core/util/Collection#function-splice


Post by orthobridge »

Animal wrote: Wed May 24, 2023 6:46 am

You can't go behind the scenes and set _values property of the selected Collection. That is a private property, and changing it will break the class.

You can either use the List methods https://bryntum.com/products/calendar/docs/api/Core/widget/List#function-deselectAll then https://bryntum.com/products/calendar/docs/api/Core/widget/List#function-select

Or, change the Collection in one step using https://bryntum.com/products/calendar/docs/api/Core/util/Collection#function-splice

thanks for your response, please can you share a code showing these in use. thanks


Post by Animal »

It's as simple as calling deselectAll();select(<an array of ids>) as the API docs describe.


Post by orthobridge »

Animal wrote: Thu May 25, 2023 10:23 am

It's as simple as calling deselectAll();select(<an array of ids>) as the API docs describe.

Thanks it does work as expected, but I am now facing new issues with approach, I am unable to deselect resources again or close a resource with the X button. What am I doing wrong?


Post by Animal »

Setting the selection on startup won't affect that. We need to see exactly what you're doing.


Post by Animal »

It sounds like that code is being executed again when you deselect resources again or close a resource with the X button, so it's reselecting.


Post by orthobridge »

Animal wrote: Fri May 26, 2023 9:19 am

It sounds like that code is being executed again when you deselect resources again or close a resource with the X button, so it's reselecting.

Here is what i am doing

 listeners: {
	dataChange({}) {
	calendar.widgetMap.resourceFilter.selectAll()
	}
}

You are right, it is indeed reselecting, i am selecting all when data changes because different resources are loaded for each date but it seems deselecting a resource emits a dataChange too. Is there a better way i can do it?


Post by Animal »

Deselecting a resource will cause the eventStore to recalculate its filtered state.

This will emit a change event (Not a "dataChange" event) with the triggering action:

Screenshot 2023-05-26 at 10.49.13.png
Screenshot 2023-05-26 at 10.49.13.png (189.26 KiB) Viewed 275 times

Post by orthobridge »

Deselecting a resource does fire the calendar dataChange event too


Post Reply