Our state of the art Gantt chart


Post by rahulranjan »

Hi
I want to disable save button of task editor if any validation of field fails

Post by pmiklashevich »

Having button disabled based on validation is not supported out of the box. But saving/closing editor which has invalid fields should be not possible by default. It looks like a bug to me. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/8976-prevent-task-editor-from-closing-if-there-is-an-invalid-field/details

Pavlo Miklashevych
Sr. Frontend Developer


Post by rahulranjan »

Hi
After click on save button how can i validate the fields . before sending it to server.

Post by pmiklashevich »

Sending data to server is not related to the editor closing.

Please reply on the questions below:
1. Do you use autoSync?
2. Do you want to validate data before sending it to the server only,
or you want to validate data in the editor form fields before close the editor?
3. Do you want to prevent data from saving and editor from closing if there are invalid fields? (Doesn't work, see https://app.assembla.com/spaces/bryntum/tickets/8976)

Please explain full scenario with a screenshot to show what exactly you want to achieve.

Validation is done on fields level, please see https://www.bryntum.com/docs/gantt/#Common/widget/Field#property-isValid

Pavlo Miklashevych
Sr. Frontend Developer


Post by rahulranjan »

Hi
1. Do you use autoSync? _ No
2. Do you want to validate data before sending it to the server only,
or you want to validate data in the editor form fields before close the editor? - Both solution will be helpful for me.
3. Do you want to prevent data from saving and editor from closing if there are invalid fields? - Yes

Post by pmiklashevich »

Ok, so there are 2 problems:

1. Validate data before sync to server.
You can listen to beforesync event on the project, check if your data is valid and return "false" to prevent sync if the data is not valid. https://www.bryntum.com/docs/gantt/#Gantt/model/ProjectModel#event-beforesync

2. Validate fields in TaskEditor to be able to prevent from saving not valid data:
2.1 "Save" button should be blocked in case any of task editor fields is invalid. It's broken. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/8976-prevent-task-editor-from-closing-if-there-is-an-invalid-field/details
2.2 We should support custom fields validation, but we don't have a concept of forms. I've created a feature request to introduce Form class and provide form validation. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/9057-provide-form-mixin-to-support-custom-form-validation/details

Regards,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by rahulranjan »

Hi
I am using below but it is not getting invoked
this.project.on("beforesync", () => {
      console.log("TEST BY Validate");
    });
When i click on save button of task editor

Post by pmiklashevich »

It's not getting invoked since autoSync is false. Please call project.sync() manually after Save.

Pavlo Miklashevych
Sr. Frontend Developer


Post by rahulranjan »

Hi
Can you please let me know how to call it manually ? Where to place it not i tried but unable to achieve it.

Post by pmiklashevich »

We don't have a public way to catch the moment when task editing is applied, but meanwhile you can use afterSave hook of the TaskEditor:
new Gantt({
    features : {
        taskEdit : {
            editorConfig : {
                afterSave : function() {
                    debugger
                }
            }
        }
    },

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply