Skip to content

Commit c1fa5f3

Browse files
authored
Fix backbone view/backend sync issue when editing cells (#140)
* fix view/back end sync issues * remove spaces
1 parent 0b1b289 commit c1fa5f3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/datagrid.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ export
116116
this.data_model.changed.connect((sender: ViewBasedJSONModel, args: any) => {
117117
if (args.type === 'cells-changed') {
118118
const value = this.data_model.data(args.region, args.row, args.column);
119-
const datasetRow = this.data_model.getDatasetRowFromView(args.region, args.row)
119+
const datasetRow = this.data_model.getDatasetRowFromView(args.region, args.row);
120+
// Getting a copy of the data and update the front-end model in place
121+
const newData = this.get('_data');
122+
newData.data[datasetRow][args.column] = value;
123+
this.set('_data', newData);
124+
// Update backend with new data
120125
this.comm.send({
121126
method: 'custom',
122127
content: {
@@ -129,7 +134,6 @@ export
129134
}, null);
130135
}
131136
});
132-
133137
this.updateTransforms();
134138
this.trigger('data-model-changed');
135139
this.updateSelectionModel();

0 commit comments

Comments
 (0)