Our state of the art Gantt chart


Post by jhughesoneplan »

Using your aggregate demo change the project model to:

project = new ProjectModel({
        taskModelClass : MyTaskModel,
autoSync: true,
        transport      : {
            load : {
                url : '../_datasets/launch-saas.json'
            },
            sync: {
                url : '../_datasets/launch-saas.json'
            }
        },
        // This config enables response 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
    })

Change a cost of a leaf node. Notice it does not send a sync request for any of the parent nodes. This is a current critical issue for us. Is there a quick fix for this?


Post by Animal »

This seems like a bug in the implementation. Here's a ticket to track: https://github.com/bryntum/support/issues/3802


Post by Animal »

As a workaround, you can set up an Override on that class (grid.column.AggregateColumn) of these two methods:

    onRecordUpdate({ record, changes }) {
        const
            me         = this,
            { parent } = record;

        if ((me.field in changes) && parent) {
            parent.set(me.field, me.getRawValue(parent, false));
        }
    }

    getRawValue(record, set = true) {
        let value = 0;

        if (record.children) {
            const
                me       = this,
                fn       = me.function,
                isMathFn = typeof fn === 'string' && typeof Math[fn] === 'function',
                {
                    handler,
                    thisObj
                } = isMathFn ? {
                    handler : Math[fn],
                    thisObj : Math
                } : me.resolveCallback(fn);

            for (let i = 0, { length } = record.children; i < length; i++) {
                value = handler.call(thisObj, value, me.getRawValue(record.children[i]));
            }
            if (set) {
                record.setData(me.field, value);
            }
        }
        else {
            value = record[this.field];
        }
        return value;
    }

Post by jhughesoneplan »

That is getting me closer. When I edit a field it works. I have a more advanced case. The data is sent to the server it runs a calculation and then returns that calculation for that column. It then sets the column via the sync code and does a roll up. This still does not trigger an new update for the rolled up summary task.


Post by Animal »

I don't really follow. Probably best to set a breakpoint in code and step through it.


Post by jhughesoneplan »

I have a set up similar to your aggregate demo. Except the cost column is read only and is calculated on the server. You fill out effort and duration and when it saves it calculates cost and returns it. When it gets returned it then rolls up to the summary items. When it rolls up to the summary items it should submit a new sync request to update the summary items. The override only seems to account for manually updating the column. Is there another override I need to make this work


Post by alex.l »

Do you have all fields you expect to be updated in your data model? How do you update data for that summary items, throw record update? Why do you need to store it on the server if they may be calculated?

All the best,
Alex


Post by jhughesoneplan »

Yes all fields are in the model. Here is an example

Start with effort at 0 which makes cost 0
Name Effort Cost
Task 1 0 0
Task 2 0 0

Then set Effort on Task 2 to 40
Name Effort Cost
Task 1 40 0
Task 2 40 0

40 gets set for effort on task 2 and task 1 via sync

Cost gets returned for task 2
Name Effort Cost
Task 1 40 0
Task 2 40 500

Cost rolls up to summary
Name Effort Cost
Task 1 40 500
Task 2 40 500

However at this point Task 1 cost does not get submitted back to the server in a sync to be saved. So in the database Task 1 has a cost of 0 which is incorrect. Now if I make cost just an editable field and enter 500 on task 1 it works, just not when the sync updates that field.


Post by mats »

You could try calling https://www.bryntum.com/docs/grid/api/Grid/view/GridBase#function-refreshColumn to manually refresh after each sync?


Post by jhughesoneplan »

I have 1 more issue related to this. Say you have
Task1 10
---Task2 5
---Task3 5

the fix works if I change Task 3 value, Task1 then syncs. However if you just delete Task3 the total for Task1 goes to 5 but it doesnt sync the change for that task. It only syncs the removal of task3.


Post Reply