Our state of the art Gantt chart


Post by empire »

Does the Gantt provide the ability to edit baseline dates?



Post by empire »

Please provide a working example to edit the baselines from the edit task dialog.


Post by alex.l »

We do not have a UI for edit baselines.
Here is a code example of how to change baseline

taskRecord.baselines.getAt(0).endDate = newEndDate;

Here is a guide how to customize Task Editor https://bryntum.com/products/gantt/docs/guide/Gantt/customization/taskedit

Add custom tabs and fields with code snippets https://bryntum.com/products/gantt/docs/guide/Gantt/customization/taskedit#add-custom-tabs-and-fields

All the best,
Alex


Post by empire »

Can you please provide code example to then sync back to database.

Will updating a baseline date rechedule to entire baseline?


Post by alex.l »

baselines just one of fields of TaskModel record. See links I posted above.
To sync changes, use regular way how you sync changes in other fields of task records. If you use our CrudManager, you need to call
gantt.project.sync()
We have online demo here https://bryntum.com/products/gantt/examples/baselines/
Please review it.
Try in console:

// get one of tasks
taskRecord = gantt.taskStore.getAt(4); 
// change one of baselines
taskRecord.baselines.getAt(0).endDate = new Date();
// check how changes that will be sent to server look like
gantt.project.changes;

All the best,
Alex


Post by empire »

I have added new Baseline Start Date, End Date, and Duration fields to a new Baseline tab on the taskEditor. Using beforeTaskEditShow and beforeTaskSave events I can get and save the values however there is no validation on the fields.

Can you please provide sample code to add new StartDate, EndDate and Duration fields to the taskEditor that work similar to the Start, End and Duration fields on the General tab.

Also, in the beforeTaskSave event, what is the best method to detect if a field has been edited?


Post by alex.l »

I am afraid it's not something simple that I can share. It's a complex logic that not placed in one file. You need to go to sources and check how it works.
See GeneralTab.js and classes it inherits. Or start from GanttTaskEditor.js and go down into classes to see the logic.
When you set record for the FormTab (see FormTab.js and EditorTab.js), it will catch data from it and startDate/endDate fields will be set up accordingly.
But in case of Baseline record, I am not sure how exactly you load data and how did you set fields - in separate tab or as one of fields in common form which already have TaskModel record loaded.

endDate field has https://bryntum.com/products/gantt/docs/api/SchedulerPro/widget/EndDateField#config-eventRecord property to set up some validations. Also set up
https://bryntum.com/products/gantt/docs/api/SchedulerPro/widget/EndDateField#config-project
https://bryntum.com/products/gantt/docs/api/SchedulerPro/widget/StartDateField#config-project
for end and start date fields to catch calendar settings.

I think the best for you might be to only set eventRecord (as baseline record instance) and project in beforeTaskEditShow or other method where you load baseline data into the form and all the rest that required for you, add into https://bryntum.com/products/gantt/docs/api/SchedulerPro/feature/TaskEdit#event-beforeTaskSave which is preventable and good for validation.

Also, in the beforeTaskSave event, what is the best method to detect if a field has been edited?

Yes, beforeTaskSave is a good place for validation and other checks that you need to do before saving.

If you need help in development, please contact our sales for Professional Services and our developers will help you! https://www.bryntum.com/services

All the best,
Alex


Post Reply