Our state of the art Gantt chart


Post by mats »

As I wrote:

Use Grid.view.mixin.GridSelection#function-deselectRow

And you can use https://bryntum.com/docs/gantt/api/Grid/view/GridBase#function-scrollRowIntoView


Post by shimnx »

Is it used in this way

listeners: {
                        async selectionChange(changed) {
                            console.log(changed);
                            if(changed.action == "deselect"){
                                const result = await MessageDialog.confirm({
                                    title: 'The big question',
                                    message: 'Do you really want to select?',
                                    okButton: 'Yes',
                                    cancelButton: 'No'
                                });

                            if (result != MessageDialog.okButton) {
                                console.log(changed);
                                this.scrollRowIntoView()
                                // call deselect on your row
                            }
                        }

                    }
                },

Post by mats »

Ok great, is it working the way you like now?


Post by shimnx »

This method does not seem to work, for example: I have a task assigned to A, at this time I go to modify the assignor, from A to B, and then the confirmation box appears, at this time I click NO, the assignor still changes to B, when I click NO, the assignor should be A


Post by mats »

Sure, you don't seem to call Grid.view.mixin.GridSelection#function-deselectRow


Post by shimnx »

How should I call it?


Post by alex.l »

Try grid.deselectRow(record) ?

All the best,
Alex


Post by shimnx »

Where gird and Record come from

/**
 * Gantt configuration file
 */

import '../lib/GanttToolbar.js';
import '../lib/StatusColumn.js';
import Task from '../lib/Task.js';
import { Gantt, MessageDialog } from '@bryntum/gantt/gantt.lite.umd.js';
const ganttConfig = {
    dependencyIdField: 'wbsCode',
    listeners: {
        beforeEventDelete() {
            console.log('delete');
        }
    },
    project: {

    // Let the Project know we want to use our own Task model with custom fields / methods
    taskModelClass: Task,

    autoLoad: false,

    // The State TrackingManager which the UndoRedo widget in the toolbar uses
    stm: {
        autoRecord: true
    },

    // 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
},

startDate: '2019-01-12',
endDate: '2019-03-24',
resourceImageFolderPath: 'assets/users/',
columns: [
    { type: 'wbs' },
    { type: 'name', width: 250 },
    { type: 'startdate' },
    { type: 'duration' },
    {
        type: 'resourceassignment', width: 120, showAvatars: true,

        editor: {

            picker: {
                listeners: {
                    async selectionChange(changed) {
                        console.log(changed);
                        if(changed.action == "deselect"){
                            const result = await MessageDialog.confirm({
                                title: 'The big question',
                                message: 'Do you really want to select?',
                                okButton: 'Yes',
                                cancelButton: 'No'
                            });

                            if (result != MessageDialog.okButton) {
                                console.log(changed);
                                this.scrollRowIntoView()
                                this.deselectRow()
                                // call deselect on your row
                            }
                        }

                    }
                },
                selectionMode: {
                    rowCheckboxSelection: true,
                    multiSelect: false,
                    showCheckAll: false,

                },

                features: {
                    filterBar: true,
                    group: 'resource.orgCode',
                    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: 200,
                // }],
            },

        }
    },
    { type: 'percentdone', showCircle: true, width: 70 },
    {
        type: 'predecessor',
        width: 112
    },
    {
        type: 'successor',
        width: 112
    },
    { 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'
}
};

export default ganttConfig;

Post by tasnim »

You're one is right this.deselectRow() just need to add the record from changed changed like this this.deselectRow(changed.selected[0]).


Post by shimnx »

An error occurs when I trigger this.deselectrow (changed.selected[0]),you can run my demo and check,thank you!

Attachments
advanced examples.zip
(137.49 KiB) Downloaded 42 times

Post Reply