Our state of the art Gantt chart


Post by shimnx »

All I have now is an ‘event’ parameter.I don't know how to get the change data I need like this:

 listeners: {
                change(event) {
                    console.log(JSON.stringify(event.store.toJSON()))
                    // [{"id":"44de0dcb-29d4-410e-98ee-8f38984cc1dc","parentIndex":0,"startDate":"2021-11-10T00:00:00+08:00","endDate":"2021-11-12T00:00:00+08:00","duration":2,"durationUnit":"day","cls":"","iconCls":null,"style":null,"name":"23","direction":"Forward","manuallyScheduled":false,"constraintType":"startnoearlierthan","constraintDate":"2021-11-10T00:00:00+08:00","percentDone":0,"inactive":null,"effort":24,"effortUnit":"hour","effortDriven":false,"schedulingMode":"Normal","expanded":null,"baselines":[],"note":null,"parentId":null,"showInTimeline":null,"rollup":null,"deadlineDate":null,"taskIconCls":null,"phantomId":null},{"id":"0b5c90db-b005-4670-95f8-9cc5c835a2a0","parentIndex":1,"startDate":"2021-11-14T00:00:00+08:00","endDate":"2021-11-15T00:00:00+08:00","duration":1,"durationUnit":"day","cls":"","iconCls":null,"style":null,"name":"1212122332","direction":"Forward","manuallyScheduled":false,"constraintType":"startnoearlierthan","constraintDate":"2021-11-12T00:00:00+08:00","percentDone":0,"inactive":null,"effort":24,"effortUnit":"hour","effortDriven":false,"schedulingMode":"Normal","expanded":null,"baselines":[],"note":null,"parentId":null,"showInTimeline":null,"rollup":null,"deadlineDate":null,"taskIconCls":null,"phantomId":null},{"id":"563da802-ec77-41fa-bb12-abf362e516a0","parentIndex":2,"startDate":"2021-11-10T00:00:00+08:00","endDate":"2021-11-11T00:00:00+08:00","duration":1,"durationUnit":"day","cls":"","iconCls":null,"style":null,"name":"New task","direction":"Forward","manuallyScheduled":false,"constraintType":"startnoearlierthan","constraintDate":"2021-11-10T00:00:00+08:00","percentDone":0,"inactive":null,"effort":24,"effortUnit":"hour","effortDriven":false,"schedulingMode":"Normal","expanded":null,"baselines":[],"note":null,"parentId":null,"showInTimeline":null,"rollup":null,"deadlineDate":null,"taskIconCls":null,"phantomId":null}]
                }
            },

Post by alex.l »

Store change and selection change are very different events. Selection change doesn't have any updated tasks since it doesn't update any tasks, it's only change the selection in the list.
I am not sure what are you trying to achieve, but if you want to catch assignments change, try to use https://bryntum.com/docs/gantt/api/Gantt/widget/AssignmentField#event-change instead. It has newValue and oldValue, and you always can get selected state. You may try to format it as you need using these data, before forward it further.

All the best,
Alex


Post by shimnx »

Could you please give me some code about https://bryntum.com/docs/gantt/api/Gantt/widget/AssignmentField#event-change,where is it should be writing?


Post by saki »

You need to write it on the editor, not on the column itself. The example:

        {
            type        : 'resourceassignment',
            width       : 120,
            showAvatars : true,

            editor : {
                listeners : {
                    change(context) {
                        console.log(context);
                    }
                }
            }
        },

Post by shimnx »

OK.Thank you!
And can I get all of the data after change the 'resourceassignment' from the editor

{
            type        : 'resourceassignment',
            width       : 120,
            showAvatars : true,

        editor : {
            listeners : {
                change(context) {
                    console.log(context);
                }
            }
        }
    },

What method should I use?


Post by saki »

Re 1. Yes, take a look at the console.log. All the needed data is wrapped in context object.

What method should I use?

I'm not sure what you mean by this.


Post by shimnx »

Now I want to get all of the gantt data from the editor.How to get?


Post by saki »

Now I want to get all of the gantt data from the editor.How to get?

The editor above is only the field responsible for changing value of resource assignment field, therefore you cannot find "all of the gantt data" in it.

However, you can access the gantt instance which contains project and that contains all stores. Just follow this guide: https://bryntum.com/docs/gantt/guide/Gantt/integration/angular#bryntum-gantt-api-instance


Post by shimnx »

 ganttConfig = {
        project: {
            listeners: {
                change(context) {
                    console.log(context)
                }
            },
            // 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,
        },
        dependencyIdField: 'id',
        startDate: '2020-10-10',
        endDate: '2021-12-24',
        columns: [
            { type: 'wbs' },
            { type: 'name', width: 250 },
            { type: 'startdate' },
            { type: 'duration' },
            {
                type: 'resourceassignment', width: 120, showAvatars: true,

            editor: {
                listeners: {
                    change(context) {
                        console.log(this)
                    }
                },
                picker: {
                    height: 350,
                    width: 450,
                    selectionMode: {
                        rowCheckboxSelection: true,
                        multiSelect: false,
                        showCheckAll: false,

                    },

                    features: {
                        filterBar: true,
                        group: 'resource.name',
                        headerMenu: false,
                        cellMenu: false,
                    },
                    // The extra columns are concatenated onto the base column set.
                    columns: [{
                        text: 'Calendar',
                        // Read a nested property (name) from the resource calendar
                        field: 'resource.name',
                        filterable: false,
                        editor: false,
                        width: 85,
                    }],
                },

            }
        },
        { type: 'percentdone', showCircle: true, width: 70 },
        {
            type: 'predecessor',
            width: 112,
            dependencyIdField: 'wbsCode',
        },
        {
            type: 'successor',
            width: 112,
            dependencyIdField: 'wbsCode',
        },
        { type: 'schedulingmodecolumn' },
        { type: 'calendar' },
        { type: 'constrainttype' },
        { type: 'constraintdate' },
        { type: 'statuscolumn' },
        {
            type: 'date',
            text: 'Deadline',
            field: 'deadline'
        },
        { type: 'addnew' }
    ],

    subGridConfigs: {
        locked: {
            flex: 3
        },
        normal: {
            flex: 4
        }
    },

    columnLines: false,
    features: {

        rollups: {
            disabled: true
        },
        baselines: {
            disabled: true
        },
        progressLine: {
            disabled: true,
            statusDate: new Date(2019, 0, 25)
        },
        filter: true,
        dependencyEdit: true,
        timeRanges: {
            showCurrentTimeLine: true
        },
        labels: {
            left: {
                field: 'name',
                editor: {
                    type: 'textfield'
                }
            }
        }
    },

    tbar: {
        type: 'gantttoolbar'
    },
};

How can I get full Gantt Data from the 'change' method.

{
                type: 'resourceassignment', width: 120, showAvatars: true,

            editor: {
                listeners: {
                    change(context) {
                        How to do?????????????????
                    }
                },
                picker: {
                    height: 350,
                    width: 450,
                    selectionMode: {
                        rowCheckboxSelection: true,
                        multiSelect: false,
                        showCheckAll: false,

                    },

                    features: {
                        filterBar: true,
                        group: 'resource.name',
                        headerMenu: false,
                        cellMenu: false,
                    },
                    // The extra columns are concatenated onto the base column set.
                    columns: [{
                        text: 'Calendar',
                        // Read a nested property (name) from the resource calendar
                        field: 'resource.name',
                        filterable: false,
                        editor: false,
                        width: 85,
                    }],
                },

            }
        },

The format I need is like this

{
    eventsData : [...],
    resourcesData : [...],
    dependenciesData : [...],
    assignmentsData : [...]
}

Post by mats »


Post Reply