Our state of the art Gantt chart


Post by shimnx »

How do I set up this form validation manually

Attachments
屏幕截图 2022-05-17 134703.png
屏幕截图 2022-05-17 134703.png (23.37 KiB) Viewed 299 times

Post by tasnim »

Please check these :
https://bryntum.com/docs/gantt/api/Core/widget/DurationField#config-min
Is it what you are looking for?
if yes, then if you want 1 to be valid then you would need to change min

Best regards,
Tasnim


Post by shimnx »

Is that right? This minimum I want to get dynamically, is there any way to listen to the current row and set the minimum

 columns: [
            ...
            {
                type: 'effort',
                picker: {

                // The extra columns are concatenated onto the base column set.
                columns: [{
                   min:5
                }],
            },

        },
       
    ],

Post by mats »

Sure this is simple:

gantt.on('beforeCellEditStart', ({ editorContext }) => {
    const { column, record } = editorContext;

if (column.constructor.type === 'effort') {
    editorContext.editor.min = '5d';
}
});

Docs: https://bryntum.com/docs/gantt/api/SchedulerPro/widget/EffortField#config-min

Docs: https://bryntum.com/docs/gantt/api/Grid/feature/CellEdit#event-beforeCellEditStart


Post by shimnx »

Is that right? It doesn't seem to work

ganttConfig = {

    listeners: {
        beforeEventDelete(event) {
            console.log(event);
            return false
        },
        beforeFinishCellEdit(event) {
            console.log(event)
            if (event.inputField.$$name === 'EffortField'){
                console.log(event.value.magnitude,event.record.originalData.BookedHours)
                if(event.value.magnitude<event.record.originalData.BookedHours){
                    MessageDialog.alert({
                        message: `The effort cannot be less than the book hours(${event.record.originalData.BookedHours}) already filled in!`
                    });
                    return false
                }else{
                    return true
                }
            }
        
        },
        beforeCellEditStart({ editorContext }){
            console.log(editorContext)
            if (editorContext.column.constructor.type === 'effort') {
                editorContext.editor.min = '5d';
            }
        }

    },
  }

Post by tasnim »

Working fine here. Please check if you have correctly added the [listeners] property in the HTML file


Post Reply