How do we listen for switch events when we switch the assigners, because we need some logic to determine whether the selected person can be assigned
Support Forum
Hi,
You need to use selectionChange
event.
Please check docs: https://bryntum.com/docs/scheduler/api/Grid/view/mixin/GridSelection#event-selectionChange
Here is an example of how to use it:
{ type : 'resourceassignment', width : 120, showAvatars : true, editor : {
picker : {
listeners : {
selectionChange() {
console.log('changed');
}
}
}
}}
Best regards,
Tasnim
Please see updated post above, the correct event is https://bryntum.com/docs/scheduler/api/Grid/view/mixin/GridSelection#event-selectionChange
All the best,
Alex
Is that right
project: {
listeners: {
selectionChange(event){
console.log(event)
},
},
// Let the Project know we want to use our own Task model with custom fields / methods
taskModelClass: Task,
transport: {
// load: {
// url: 'assets/data/launch-saas.json'
// },
sync: {
url: '/some/sync/url'
}
},
autoLoad: true,
// The State TrackingManager which the UndoRedo widget in the toolbar uses
stm: {
autoRecord: true
},
phantomIdField: 'PhantomId',
// This config enables responses validation and dumping of found errors to the browser console.
// It's meant to be used as a development stage helper only so please set it to false for production systems.
validateResponse: true,
},
Thank you very much! I did listen for a choice change in this event. But how do I block selection in this event, because we have some logic that requires the user to pop up a popup when selecting a person, and when the user clicks ok, it's really selected, and when the user clicks Cancel, the person who should cancel this selection is returned to the person who was selected last time (i.e. clicking the cancel button).
In your listener you can simply show your dialog and deselect the row that was selected:
const result = await MessageDialog.confirm({
title : 'The big question',
message : 'Do you really want to select?',
okButton : 'Yes',
cancelButton : 'No'
});
if (result !== MessageDialog.okButton) {
// call deselect on your row
}
Docs:
https://bryntum.com/docs/scheduler/api/Grid/view/mixin/GridSelection#function-deselectRow
https://bryntum.com/docs/scheduler/api/Core/widget/MessageDialog#function-confirm