File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
app/result/components/viewer/structure Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ def _render(self):
32
32
self .atom_coordinates_table ,
33
33
]
34
34
self .atom_coordinates_table .observe (self ._change_selection , "selected_rows" )
35
+ # Listen for changes in self.widget.displayed_selection and update the table
36
+ self .widget .observe (self ._update_table_selection , "displayed_selection" )
35
37
36
38
# HACK to resize the NGL viewer in cases where it auto-rendered when its
37
39
# container was not displayed, which leads to a null width. This hack restores
@@ -66,3 +68,7 @@ def _generate_table(self, structure):
66
68
def _change_selection (self , _ ):
67
69
selected_indices = self .atom_coordinates_table .selected_rows
68
70
self .widget .displayed_selection = selected_indices
71
+
72
+ def _update_table_selection (self , change ):
73
+ selected_indices = change .new
74
+ self .atom_coordinates_table .selected_rows = selected_indices
Original file line number Diff line number Diff line change @@ -1282,6 +1282,20 @@ class TableWidget(anywidget.AnyWidget):
1282
1282
1283
1283
drawTable();
1284
1284
model.on("change:data", drawTable);
1285
+ model.on("change:selected_rows", (e) => {
1286
+ const newSelection = model.get("selected_rows");
1287
+ // Update row selection based on selected_rows
1288
+ const rows = domElement.querySelectorAll('tr');
1289
+ rows.forEach((row, index) => {
1290
+ if (index > 0) {
1291
+ if (newSelection.includes(index - 1)) {
1292
+ row.classList.add('selected-row');
1293
+ } else {
1294
+ row.classList.remove('selected-row');
1295
+ }
1296
+ }
1297
+ });
1298
+ });
1285
1299
el.appendChild(domElement);
1286
1300
}
1287
1301
export default { render };
You can’t perform that action at this time.
0 commit comments