Our state of the art Gantt chart


Post by lanpeng »

Hello bryntum team,
We have a specific requirement: to assign a task to multiple people, and then assign some working hours to each person. In your use case, I have several functions that I cannot find corresponding methods to implement. Can you provide me with some support?
I uploaded my use case ,could you please give me some code snippet based it?

  1. As shown in p1 , After selecting these members and filling in the effort, the total effort of this task should be modified to the total effort of the selected members after the user clicks the save button . How can i achive it?
  2. As shown in p2. in this case , if done hours greater than 0 ,users can not deselect it. How should I make this restriction.
Attachments
p2.png
p2.png (192.47 KiB) Viewed 316 times
p1.png
p1.png (188.56 KiB) Viewed 316 times
use-case.zip
(68.55 KiB) Downloaded 95 times

Post by marcio »

Hey lanpeng,

Thanks for reaching out and providing a demo.

Based on the demo, you can use the following event listeners, for p1, you can see the listener that is added on saveBtn click.
For p2, we have https://bryntum.com/products/gantt/docs/api/Gantt/widget/AssignmentGrid#event-beforeSelectionChange that by returning false makes the row not be selected.

picker: {
                    listeners: {
                        beforeShow({ source }) {
                            source.widgetMap.saveBtn.addListener('action', (ev) => {
                                // here you can access source.selectedRows to get the selection
                                // update the total based on selected rows
                            })
                            source.columns.get('units').hidden = true;
                        },
                        beforeSelectionChange(data){
                            if(condition)
                                return false;
                        }

Best regards,
Márcio


Post by lanpeng »

Hi marcio , thanks for your reply.
For the first problem , The solution you provided is effective .
For the second, I found the eventListeners "beforeSelectionChange" has already triggered When the user opens resourceassignment editor, and then when the user selects or deselects resources, this event will be triggered twice.
p3 is the output when I open the editor, and p4 is the output when I select 'celia' .
I expect to perform a validation before the user deselects a certain resource data, checking whether the field doneHours in its row data is greater than 0. If it is, the user cannot deselect this resource data.

Attachments
p4.png
p4.png (283.61 KiB) Viewed 263 times
p3.png
p3.png (303.94 KiB) Viewed 263 times

Post by lanpeng »

sorry my mistake.
Correct it : p4 is the output after I open the editor, and p3 is the output when I select 'celia' .


Post by marcio »

Hey lanpeng,

That's the expected behavior, that method is called when the user tries to select and also when deselecting some row, you can check that using the same event listener like this

beforeSelectionChange(data){
	const { action, deselected } = data;
	if(action === 'deselect') {
		// Check if deselected contains info and if the doneHours is different than 0
		// Boolean(0) will be false, so it should allow to deselect, if is different
		// the deselection will be cancelled
		return deselected[0] && !Boolean(deselected[0].doneHours);
	}
	return true;
}

Best regards,
Márcio


Post by lanpeng »

Hi marcio,
Based on the code you provided me, I conducted a test . But it still did not work.
My code snippet is as below.

		beforeSelectionChange(data){
                            const { action, deselected } = data;
                            if(action === 'deselect') {                               
return false } return true },

Based on this code, I believe that under no circumstances can users deselect resource data .
But in fact, i can freely deselect it .

Attachments
media.mp4
(1.7 MiB) Downloaded 98 times

Post by marcio »

Hey,

Thanks for the video, I was able to reproduce that too and created a ticket to fix that https://github.com/bryntum/support/issues/8695

Best regards,
Márcio


Post by nickolay »

@lanpeng Hi, it seems this issue has been already fixed - see the video I've uploaded into the ticket. Please try reproducing it with the latest version of our code and let me know?


Post Reply