bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Make State object configurable for data it saves #9823

Closed chuckn0rris closed 1 month ago

chuckn0rris commented 3 months ago

Some callback function on save/restore for stateful objects might make things easier.

Forum post

Hi, I'd like to consult with you on a workaround for a problem i noticed after updating to v6.0.1

Problem : We are preserving the state of the columns. From v6.0.1, state.columns property seems to also store text property. However we use salesforce labels for text properties. so when user saves the state in japanese language. changes the salesforce language to english. then loads the screen again, since the saved state was in japanese language the column header labels are also in japanese language.

As a work around, I thought not to save the text property while saving the states.

A small code snippet would be as follows.

let savedGanttSetting = this.parent.state;
const ganttColumns = this._columnsWithoutText(this.parent.state.columns);
savedGanttSetting.columns = ganttColumns;
StorageUtil.setLocalStorage(savedGanttSetting, this.saveGanttSettingStorageKey);

_columnsWithoutText(columns) {
      return columns.map(({text, ...column}) => column);
    }

this work around fixes the problem since i am not storing the text property the labels are loaded according to salesforce language and not the previosly stored state. However, I wanted to consult with you to make sure this is a safe way of handling this. Please let me know if you think there is any risk for this solution.

Thank you.

chuckn0rris commented 1 month ago

Duplicated. Will be fixed in original one https://github.com/bryntum/support/issues/9892