support
support copied to clipboard
Gantt State is not persisting columns added using `addNew` column
Hi,
When a new column is added using "New Column", reloading the gantt is not recreating columns added. Attached sample here.
Reproducible in gantt/examples/state
Steps:
Run attached sample add any column using New Column Make some dummy changes to script and apply changes. Observe Newly added columns are not restored.
import { AjaxHelper, AsyncHelper, StringHelper, StateProvider, Toast, Gantt } from '../../build/gantt.module.js?474872';
import shared from '../_shared/shared.module.js?474872';
const stateId = 'mainGantt';
function launch() {
const gantt = new Gantt({
appendTo : 'container',
dependencyIdField : 'sequenceNumber',
// The key used to automatically save this widget's state in the page's state provider
stateId,
// If start/end dates are not provided, they'd be inferred from the project and will override dates restored from
// the state
startDate : new Date(2019, 0, 13),
endDate : new Date(2019, 2, 24),
features : {
filter : true
},
project : {
autoLoad : true,
transport : {
load : {
url : '../_datasets/launch-saas.json'
}
}
},
tbar : [
{
type : 'checkbox',
ref : 'autoSaveCheckbox',
label : 'Auto save',
value : true,
onChange({ checked }) {
gantt.stateId = checked ? stateId : null;
}
},
{
type : 'button',
ref : 'resetButton',
color : 'b-red',
icon : 'b-fa b-fa-times',
text : 'Reset to default',
tooltip : 'Resets application to the default state',
onAction() {
gantt.resetDefaultState();
Toast.show('Default state restored');
}
}
],
columns : [
// To persist column state it is better to explicitly specify an id
{ id : 'name', type : 'name', width : 250 },
{ id : 'startDate', type : 'startdate', width : 150 },
{ id : 'duration', type : 'duration', width : 150 },
{ id : 'predecessors', type : 'predecessor', width : 150 },
{ id : 'effort', type : 'effort', width : 150, hidden: true },
{ id : 'addnew', type : 'addnew', width : 150 }
],
// Custom task content, display task name on child tasks
taskRenderer({ taskRecord }) {
if (taskRecord.isLeaf && !taskRecord.isMilestone) {
return StringHelper.encodeHtml(taskRecord.name);
}
}
});
}
StateProvider.setup('local');
launch();
test / progress pushed to branch 8876-state
hey, any update on this issue?
@vloax Implemented, awaiting review/merge