Page 1 of 1

[VUE] Anyway to select only single resource

Posted: Mon Apr 19, 2021 9:21 pm
by sanjeeva.shrivastava

Product: Scheduler Pro 4.1.0

In the event editor, we are able to select multiple resources. Can we restrict to select only one resource?


Re: [VUE] Anyway to select only single resource

Posted: Mon Apr 19, 2021 10:08 pm
by mats

Seems we have a small bug preventing this. Once https://github.com/bryntum/support/issues/2697 is fixed, you can use:

const scheduler = new SchedulerPro({
    features : {
        taskEdit : {
            items : {
                generalTab      : {
                    items : {
                        resourcesField : {
                            multiSelect : false
                        }
                    }
                }
            }
        }
    }
})

Re: [VUE] Anyway to select only single resource

Posted: Sat Feb 18, 2023 1:34 am
by muhabbil

Hey Matt,
I tried to use the snippet which you shared above but it did not work for me. Can you let me know what i am missing as my end goal is to select single resource against task?


Re: [VUE] Anyway to select only single resource

Posted: Sat Feb 18, 2023 11:29 am
by mats

Sure! Please share your code and we'll have a look.


Re: [VUE] Anyway to select only single resource

Posted: Sun Feb 19, 2023 8:24 pm
by muhabbil

Hey Matt, i have used following snipped in salesforce lwc. Please note that i will be adding resources at task row level.

Problem # 01: Select one resource from given resources list against task row
Problem # 02: We have one column in gantt chart tasks named "Team" which is dropdown with values of "Team1, Team2" etc. Please nore that Team1 has different resources, Team2 has different resources and so on. We want to render resources value at each task row based on the selected team. Once resources column render based on selected team, we want to select one resource. Resources rendering logic should work once gantt chart is loaded with predefined team value or if user change the team value, update the resources list against that row.

Can you help me with these problem statements?

const gantt = new bryntum.gantt.Gantt({
    tree: true,
    transformFlatData: true,
    features : {
        taskEdit : {
            items : {
                generalTab      : {
                    items : {
                        resourcesField : {
                            multiSelect : false
                        }
                    }
                }
            }
        }
    }
})

Re: [VUE] Anyway to select only single resource

Posted: Mon Feb 20, 2023 1:31 pm
by alex.l

Hi muhabbil,

The solution above is provided for SchedulerPro. Gantt doesn't support singleAssignment mode.
I am afraid, to reach that you'll need to override all UI components that allow to assign resources, or hide them and use your own implementation instead.
Here is the guide how to customize TaskEditor https://bryntum.com/products/gantt/docs/guide/Gantt/customization/taskedit#customizing-the-tabs-and-the-fields


Re: [VUE] Anyway to select only single resource

Posted: Mon Feb 20, 2023 4:57 pm
by muhabbil

Hey Alex,
Thanks for the details.

As per my understanding if i want to implement single assignment mode, i need to override default assignment editor with custom task editor?

Can you provide details about problem statement # 02?


Re: [VUE] Anyway to select only single resource

Posted: Tue Feb 21, 2023 4:05 am
by alex.l

Hi muhabbil,

Sorry for ignoring #2, looks like I posted before finished.
Few mre words about #1.
You don't need to override taskEditor, you need to customize/replace field that used to select resource.
Second place to change is https://bryntum.com/products/gantt/docs/api/Gantt/column/ResourceAssignmentColumn. You'll need to replace it with single selection combo with resources list. As far as I understood, #2 is exactly about that.
There might be required to change logic on data level too, beforeAdd, beforeUpdate events of a store will help to add tricks.
I cannot give you ready solution, unfortunately. We never did it before. But we can assist with problems you face during your development. We also have Professional Services, if you want us to implement it for you https://www.bryntum.com/services

#2 As far as I understood, you have 2 columns: 1st for team and 2nd for resource.
When you select team, you need to filter resources to have only those who belong to the team.
Basically, you need to use https://bryntum.com/products/gantt/docs/api/Gantt/feature/CellEdit#event-beforeCellEditStart event, and apply filter for editor.store according to record.team value.

Here is a pseudo code to show what I meant.

gantt.on('beforeCellEditStart', ({ editorContext }) => {
	if (editorContext.column.field != 'resources') {
		return true;
	}
	editorContext.editor.store.clearFilters();
	editorContext.editor.filter((r) => r.team === editorContext.record.team);

})

https://bryntum.com/products/gantt/docs/api/Core/data/Store#function-filter
https://bryntum.com/products/gantt/docs/api/Core/data/Store#function-clearFilters


Re: [VUE] Anyway to select only single resource

Posted: Tue Feb 21, 2023 11:56 pm
by alex.l

I've opened a feature request to add a demo with single assignment mode in Gantt https://github.com/bryntum/support/issues/6235