了解了,请参考这段新代码来实现:
- let schemaColumns =
- spread.dataManager().tables["表1"].options.schema.columns;
- let columns = spread.dataManager().tables["表1"].columns;
- let map = {};
- for (const key in schemaColumns) {
- if (schemaColumns[key].dataName) {
- map[schemaColumns[key].dataName] = key;
- }
- }
- spread.dataManager().tables["表1"].columns = null;
- spread.dataManager().tables["表1"].options.schema.columns = null;
- spread
- .dataManager()
- .tables["表1"].fetch(true)
- .then(() => {
- let option = spread.dataManager().tables["表1"].options;
- for (const key in map) {
- let ifSet = false;
- if (spread.dataManager().tables["表1"].columns[key]) {
- ifSet = true;
- }
- delete option.schema.columns[key];
- delete spread.dataManager().tables["表1"].columns[key];
- if (ifSet) {
- option.schema.columns[map[key]] = schemaColumns[map[key]];
- spread.dataManager().tables["表1"].columns[map[key]] =
- columns[map[key]];
- }
- }
- designer.refresh();
- });
复制代码 |