Our state of the art Gantt chart


Post by shimnx »

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

Attachments
屏幕截图 2022-05-19 144150.png
屏幕截图 2022-05-19 144150.png (26.17 KiB) Viewed 515 times

Post by tasnim »

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


Post by shimnx »

I know I can listen for changes here, and when I listen for changes I need to pop up a box that says something, and then the user clicks OK to make the assignment. If I click Cancel, then I need to change the assigner to the original assigner. How do I block that


Post by shimnx »

Can you help answer it? It's urgent. Thank you very much


Post by alex.l »

All the best,
Alex


Post by shimnx »

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,
    },

Post by tasnim »

Please check above, I've updated the code snippet.


Post by shimnx »

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).


Post by mats »

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


Post by shimnx »

Thank you. Now one more question is when I hit NO, how do I unselect the current allocator and go back to the previous allocator


Post Reply