Premium support for our pure JavaScript UI components


Post by jandresampaio »

Hi,

I've searched through the examples but could not find a solution to this.

When modyfing a column row value, how to set other column value in the same row?
In our case we have an "Effort" column, and then an "EffortSum", based on the sum of the children Efforts. So when changing Effort, we would update EffortSum, which would be an aggregate column.
Something like this sketch:

Desired behavior.PNG
Desired behavior.PNG (15.95 KiB) Viewed 674 times

Thank you.


Post by pmiklashevich »

The problem is not related to the UI level. Grid just displays what is in your record. You need to solve the problem on data level. Define a new field on the TaskModel and calculate its value depending on the effort.

For example in Advanced demo:
Gantt/examples/advanced/lib/Task.js

import TaskModel from '../../../lib/Gantt/model/TaskModel.js';
import Duration from '../../../lib/Core/data/Duration.js';

// here you can extend our default Task class with your additional fields, methods and logic
export default class Task extends TaskModel {

static get fields() {
    return [
        { name : 'sumEffort', type : 'number' },
        { name : 'deadline', type : 'date' }
    ];
}

get sumEffort () {
    return this.isParent ? new Duration({
        unit      : this.effortUnit,
        magnitude : this.effort * 2
    }) : null;
}

Gantt/examples/advanced/app.js

    columns                 : [
        { type : 'wbs' },
        { type : 'name', width : 100 },
        { type : 'effort' },
        { type : 'effort', field : 'sumEffort', text : 'SUM EFFORT', editor : false },
Снимок экрана 2020-12-31 в 12.58.44.png
Снимок экрана 2020-12-31 в 12.58.44.png (151.13 KiB) Viewed 672 times

Though I'm not sure I got the logic. You just double the effort value calculated for the summary task. What is the idea behind this field (column)?

Pavlo Miklashevych
Sr. Frontend Developer


Post by jandresampaio »

Hi Pavel,

Thanks for the update.
To clarify, we named it effort but it's not a column of type "effort", it's just a number column.

This column reflects the accumulated effort of the task and all its children efforts.
As you can see in the image I've attached, users gave the main task an effort of 13 and it's children tasks 3 and 10. The sum would be 13 + 3 + 10 = 26.

What happens normally is that users create a task with a certain effort, and then create the children tasks. They would like to visualize the actual effort of the task and the accumulated value, even if it's not coherent (normally the parent task effort would have the sum of its children efforts)

Hope I've made it clear now.
Thank you.


Post by pmiklashevich »

Ok, so what you call "Effort" is actually Estimated Effort. What unit does it use (minute/hour/day/etc)? Since it's a number column it can be any? I guess it should match effortUnit in the model? I would recommend to reuse effort column which extends duration column to match the magnitude/unit pattern.

Then what you call "Efforts Sum" looks like our Effort column. Effort of the parent tasks is always a summary of its children effort. The value is not editable for parent tasks. Therefore I would have 2 columns: "Est. Effort" which holds approximate estimated effort set by users, which you can use later to compare to real effort, or validate effort changes for example.

And still I don't see any reason to add estimated effort to real effort. Am I missing something?

Pavlo Miklashevych
Sr. Frontend Developer


Post by jandresampaio »

Users want to see a sum of all individual "efforts" (if we can call it that). Like the image below:

AccumPlannedEffort.PNG
AccumPlannedEffort.PNG (17.75 KiB) Viewed 667 times

Post by pmiklashevich »

I understand your formula, I just don't understand why you sum planned effort of summary task with its children planned effort. Don't see how it can be used in real life. What does this number represent? Well, final implementation is up to you of cause. And the way to achieve this is shown above.

Cheers!

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply