Closed white-gecko closed 3 years ago
Or should I better use query
for the whole situation?
The row's data_source
is just a reference to the object that was used to create the dataframe row, while the values that are displayed in the table come from the dataframe object (data_table.df
). Early on in the datatable module's development it was more like what you're looking for where the objects themselves serve as the storage for the values, and I can see the case for that, but it ended up being a significant performance issue as tables got larger.
As things are right now, the workaround is to update the dataframe separately, e.g.:
elif key == "s":
self.selection.data_source.this.action()
self.df.set(self.selection.index, "foo", self.selection.data_source.foo)
self.refresh()
Ok, so if this is outside of the scope and contradicts your design decisions, its fine. I will use the proposed workaround (:+1:)
By the way
in your workaround
elif key == "s":
self.selection.data_source.this.action()
self.df.set(self.selection.index, "foo", self.selection.data_source.foo)
self.refresh()
the line self.df.set(self.selection.index, "foo", self.selection.data_source.foo)
doesn't do anything relevant, as self.selection.data_source.foo
is not updated at that time.
I've changed my workaround to
elif key == "s":
self.selection.data.this.action()
self.df.set(self.selection.index, "foo", self.selection.data.this.foo)
self.selection.update()
How can I access the object behind a row and call a method on it, that will also update the data displayed in the table.
I have created the following MWE to show what I want.
Checked on current unstable branch (17d1fcab44a47e486320b140654976de4546265c)
Currently the best I can do is to set
self.this = self
and then callthis.action()
subsequently I need to perform a complete refresh (keyr
) to display the updated data.Did I miss something, or how can I access the object behind the row.