Skip to content

Commit

Permalink
Revert "datatable: Row filtering fixes. Closes #13."
Browse files Browse the repository at this point in the history
This reverts commit e1c009f.
  • Loading branch information
tonycpsu committed Apr 15, 2019
1 parent 5cd51b4 commit e83a1f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Foo(BaseDataClass):
# _cls: typing.Optional[type] = None
@property
def _details(self):
return {"open": False, "disabled": False}
return {"open": True, "disabled": False}

def main():

Expand Down Expand Up @@ -337,7 +337,7 @@ def keypress(self, size, key):
elif key == "D":
self.remove_columns(len(self.columns)-1)
elif key == "f":
self.apply_filters([lambda x: x["foo"] < 5])
self.apply_filters([lambda x: x["foo"] > 20, lambda x: x["bar"] < 800])
elif key == "F":
self.clear_filters()
elif key == ".":
Expand Down
18 changes: 8 additions & 10 deletions panwid/datatable/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,12 +1204,12 @@ def apply_filters(self, filters=None):


self.filters = filters
self.invalidate()
# self.invalidate()

def clear_filters(self):
self.filtered_rows = blist(range(len(self.df)))
self.filters = None
self.invalidate()
# self.invalidate()


def load_all(self):
Expand All @@ -1234,11 +1234,10 @@ def load_more(self, position):

return False

self.requery(offset=offset)
# try:
# self.requery(offset=offset)
# except Exception as e:
# raise Exception(f"{position}, {len(self)}, {self.row_count()}, {offset}, {self.limit}, {e}")
try:
self.requery(offset=offset)
except Exception as e:
raise Exception(f"{position}, {len(self)}, {self.row_count()}, {offset}, {self.limit}, {e}")

return True

Expand Down Expand Up @@ -1279,9 +1278,8 @@ def requery(self, offset=None, limit=None, load_all=False, **kwargs):

if len(updated):
for i in updated:
if i in self.filtered_rows:
pos = self.index_to_position(i)
self[pos].update()
pos = self.index_to_position(i)
self[pos].update()
self.sort_by_column(*self.sort_by)

self._modified()
Expand Down

0 comments on commit e83a1f6

Please sign in to comment.