I am writing to follow up on the ticket we opened previously regarding the issues we are experiencing with the clear baselines.
We have encountered another issue related to the set baselines. When I set Baseline 3 for the first time without having Baselines 1 and 2 set previously, Bryntum automatically sets Baselines 1 and 2 to 3. This issue is very important to us, and we would greatly appreciate any updates you may have on the resolution process.
I am writing to follow up on the ticket we opened previously regarding the issues we are experiencing with the clear baselines.
That is a feature request and nobody else has requested it yet. So it is unlikely that it will get resolved soon. You can sponsor the development, if you want to fast track it.
Can you please describe the steps to replicate this behaviour on our end in our online demo? How you are setting the baselines?
please find the video below , and i used this code to set baseline from a menu selection .
function handleBaselineClick(index, gantt) {
if (gantt && gantt.taskStore) {
// Store the selected baseline index globally or in a shared state
window.selectedBaselineIndex = index; // Example: Using a global variable
// Refresh the grid to update renderers with the new baseline index
gantt.refresh(); // Trigger refresh (or use gantt.someGrid.refresh() if specific grid needs updating)
// Optionally, set the baseline in the task store
new Promise((resolve, reject) => {
try {
gantt.taskStore.setBaseline(index); // Example API for setting the baseline
resolve();
} catch (error) {
reject(error);
}
}).catch(error => {
console.error("Error setting baseline:", error);
});
} else {
console.error("Gantt or taskStore is undefined");
}
}
That is a feature request and nobody else has requested it yet. So it is unlikely that it will get resolved soon. You can sponsor the development, if you want to fast track it.
please find the video below , and i used this code to set baseline from a menu selection .
I do not see any data related to baselines. Please add your code in to this online demo https://bryntum.com/products/gantt/examples/advanced/ and please provide us clear steps to reproduce this issue. What is the initial value of index in the above code snippet?
and when i select from menu to set or clear ,
the set / clear baseline functions as below :
// Helper function to handle setting baseline
function handleBaselineClick(index, gantt) {
console.log("handleBaselineClick", index);
if (gantt && gantt.taskStore) {
// Store the selected baseline index globally or in a shared state
window.selectedBaselineIndex = index; // Example: Using a global variable
// Refresh the grid to update renderers with the new baseline index
gantt.refresh(); // Trigger refresh (or use gantt.someGrid.refresh() if specific grid needs updating)
// Optionally, set the baseline in the task store
new Promise((resolve, reject) => {
try {
gantt.taskStore.setBaseline(index); // Example API for setting the baseline
resolve();
} catch (error) {
reject(error);
}
}).catch(error => {
console.error("Error setting baseline:", error);
});
} else {
console.error("Gantt or taskStore is undefined");
}
}
// Helper function to handle clear baseline
function handleClearBaselineClick(index, gantt) {
console.log(`Clearing baseline ${index}`);
if (gantt && gantt.taskStore) {
gantt.suspendRefresh();
const tasksToUpdate = [];
const zeroBasedIndex = index - 1; // Convert to zero-based index
gantt.taskStore.forEach(task => {
if (task && task.baselines && typeof task.baselines.allCount === 'number') {
if (zeroBasedIndex < task.baselines.allCount) {
const baselineToRemove = task.baselines.getAt(zeroBasedIndex);
if (baselineToRemove) {
task.baselines.remove(baselineToRemove);
console.log(`Baseline ${index} removed for task:`, task);
tasksToUpdate.push(task);
} else {
console.warn(`Baseline at index ${zeroBasedIndex} not found for task:`, task);
}
} else {
console.warn(`Baseline index ${zeroBasedIndex} out of range for task:`, task);
}
} else {
console.warn(`Invalid task or baselines for task:`, task);
}
});
if (tasksToUpdate.length > 0) {
gantt.project.commitAsync()
.then(() => {
console.log(`Successfully removed baseline ${index} for all tasks.`);
})
.catch(error => {
console.error(`Failed to remove Baseline ${index}:`, error);
});
} else {
console.log(`No tasks needed updating for baseline ${index}.`);
}
gantt.resumeRefresh();
} else {
console.error("Gantt or taskStore is undefined");
}
}
the video show only the scenario and how the baselines filled .
Did I answer your question?
Yes you did answer my question but there are few things that didn't work on my end. There are lot of undefined things in the code you shared for menu.
I do get the idea. But let's take a step back and try to understand what you are trying to achieve. You are using setBaseline method to set the baseline. But this method sets the baseline for all the records on the taskStore. I have tried this behaviour in our online demo https://bryntum.com/products/gantt/examples/baselines/
And I was able to set baseline 3 without any issues:
Ok. I have attached another clip below. The startDate for the baseLine 3 is initially 13 and then it changes to 14 after setting the setBaseline being called on store. Are you referring to this behaviour? Please can you describe bit more what do you mean by this: Bryntum automatically sets Baselines 1 and 2 to 3.
I wanted to clarify something regarding the baselines in our project and the case i face. If there are no existing baselines, is it possible to set baseline 3, even if baseline 1 and 2 have not been established?
my case is when i have no baselines before , can you review the video attached above please?