Fixed bug where same DataGridQuery for all grids
This commit is contained in:
@@ -161,12 +161,13 @@ class DataGrid(MultipleInstance):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
for col_id, values in self._state.filtered.items():
|
for col_id, values in self._state.filtered.items():
|
||||||
if col_id == FILTER_INPUT_CID and values is not None:
|
if col_id == FILTER_INPUT_CID:
|
||||||
if self._datagrid_filter.get_query_type() == DG_QUERY_FILTER:
|
if values is not None:
|
||||||
visible_columns = [c.col_id for c in self._state.columns if c.visible and c.col_id in df.columns]
|
if self._datagrid_filter.get_query_type() == DG_QUERY_FILTER:
|
||||||
df = df[df[visible_columns].map(lambda x: values.lower() in str(x).lower()).any(axis=1)]
|
visible_columns = [c.col_id for c in self._state.columns if c.visible and c.col_id in df.columns]
|
||||||
else:
|
df = df[df[visible_columns].map(lambda x: values.lower() in str(x).lower()).any(axis=1)]
|
||||||
pass # we return all the row (but we will keep the highlight)
|
else:
|
||||||
|
pass # we return all the row (but we will keep the highlight)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
df = df[df[col_id].astype(str).isin(values)]
|
df = df[df[col_id].astype(str).isin(values)]
|
||||||
@@ -528,13 +529,13 @@ class DataGrid(MultipleInstance):
|
|||||||
selected = []
|
selected = []
|
||||||
|
|
||||||
if self._state.selection.selected:
|
if self._state.selection.selected:
|
||||||
#selected.append(("cell", self._get_element_id_from_pos("cell", self._state.selection.selected)))
|
# selected.append(("cell", self._get_element_id_from_pos("cell", self._state.selection.selected)))
|
||||||
selected.append(("focus", self._get_element_id_from_pos("cell", self._state.selection.selected)))
|
selected.append(("focus", self._get_element_id_from_pos("cell", self._state.selection.selected)))
|
||||||
|
|
||||||
return Div(
|
return Div(
|
||||||
*[Div(selection_type=s_type, element_id=f"{elt_id}") for s_type, elt_id in selected],
|
*[Div(selection_type=s_type, element_id=f"{elt_id}") for s_type, elt_id in selected],
|
||||||
id=f"tsm_{self._id}",
|
id=f"tsm_{self._id}",
|
||||||
#selection_mode=f"{self._state.selection.selection_mode}",
|
# selection_mode=f"{self._state.selection.selection_mode}",
|
||||||
selection_mode=f"column",
|
selection_mode=f"column",
|
||||||
**extra_attr,
|
**extra_attr,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Commands(BaseCommands):
|
|||||||
|
|
||||||
class DataGridQuery(MultipleInstance):
|
class DataGridQuery(MultipleInstance):
|
||||||
def __init__(self, parent, _id=None):
|
def __init__(self, parent, _id=None):
|
||||||
super().__init__(parent, _id=_id or "-query")
|
super().__init__(parent, _id=_id)
|
||||||
self.commands = Commands(self)
|
self.commands = Commands(self)
|
||||||
self._state = DataGridFilterState(self)
|
self._state = DataGridFilterState(self)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user