Our state of the art Gantt chart


Post by daniel.piret »

Hello Support,

When we edit a task, we see a field Manually scheduled in it - https://prnt.sc/115om9f.
We want to disable that field if it meets a condition.

We have tried the following:

  1. Disabling in 'beforeTaskEditShow' method:
     
beforeTaskEditShow({ editor, taskRecord }) { window.currentTaskRecord = taskRecord; const { generalTab } = editor.widgetMap; if (condition_satisifed) { const { manuallyScheduledField } = generalTab.widgetMap; manuallyScheduledField.editable = false; manuallyScheduledField.disabled = true; manuallyScheduledField.readOnly = true; manuallyScheduledField.input.editable = false; } }

None of the above 4 (.editable, .disabled, .readOnly, .input.editable) are working.

  1. We also tried in 'taskEdit':
taskEdit: {
                items: {
                    generalTab: {
                        items: { 
                            manuallyScheduledField: {
                                type: 'checkbox',
                                weight: 800,
                                name: 'manuallyScheduled',
                                label: 'Manually scheduled',
                                flex: '1 0 50%',
                                disabled: true,
                                readOnly: true
                            }, ......
                       }
                 }
           }
}
 

'disabled: true' and 'readOnly: true' do not work for us. Also, note that we have not added condition here just to check if this works for us, We'll have to add condition later on. Only if the condition is met, should the manuallScheduled be disabled.

Can you please help us resolbe this?


Post by pmiklashevich »

Hello,

This is a known issue. Ticket here: https://github.com/bryntum/support/issues/674
As a workaround please extend the TaskEditor and override loadEvent method

import './lib/StatusColumn.js';

import TaskEditor from '../../lib/Gantt/widget/TaskEditor.js';

class MyEditor extends TaskEditor {
    // Factoryable type name
    static get type() {
        return 'mytaskeditor';
    }

static get $name() {
    return 'MyTaskEditor';
}

loadEvent(record) {
    super.loadEvent(record);
    this.widgetMap.myManuallyScheduledField.disabled = true;
}
}

MyEditor.initClass();

new Gantt({
    features : {
        taskEdit   : {
            editorClass : MyEditor,
            items : {
                generalTab : {
                    items : {
                        myManuallyScheduledField : {
                            type     : 'checkbox',
                            weight   : 800,
                            name     : 'manuallyScheduled',
                            label    : 'Manually scheduled'
                        }
                    }
                }
            }
        },

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply