Skip to content

Commit

Permalink
Add support for TreeTable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mofojed committed May 30, 2024
1 parent e4e1895 commit 6bff70c
Showing 1 changed file with 62 additions and 3 deletions.
65 changes: 62 additions & 3 deletions py/server/deephaven/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte
def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None,
freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None,
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table:
""" Sets layout hints on the Table
""" Sets layout hints on the RollupTable
Args:
front (Union[str, List[str]]): the columns to show at the front.
Expand All @@ -274,7 +274,7 @@ def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, Lis
use the default value configured by the user and system settings.
Returns:
a new table with the layout hints set
a new rollup table with the layout hints set
Raises:
DHError
Expand Down Expand Up @@ -309,7 +309,7 @@ def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, Lis
return RollupTable(j_rollup_table=self.j_rollup_table.setLayoutHints(_j_layout_hint_builder.build()),
include_constituents=self.include_constituents, aggs=self.aggs, by=self.by)
except Exception as e:
raise DHError(e, "failed to set layout hints on table") from e
raise DHError(e, "failed to set layout hints on rollup table") from e


class TreeNodeOperationsRecorder(JObjectWrapper, _FormatOperationsRecorder,
Expand Down Expand Up @@ -403,6 +403,65 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte
except Exception as e:
raise DHError(e, "with_filters operation on TreeTable failed.") from e

def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None,
freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None,
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table:
""" Sets layout hints on the TreeTable
Args:
front (Union[str, List[str]]): the columns to show at the front.
back (Union[str, List[str]]): the columns to show at the back.
freeze (Union[str, List[str]]): the columns to freeze to the front.
These will not be affected by horizontal scrolling.
hide (Union[str, List[str]]): the columns to hide.
column_groups (List[Dict]): A list of dicts specifying which columns should be grouped in the UI.
The dicts can specify the following:
* name (str): The group name
* children (List[str]): The column names in the group
* color (Optional[str]): The hex color string or Deephaven color name
search_display_mode (SearchDisplayMode): set the search bar to explicitly be accessible or inaccessible,
or use the system default. :attr:`SearchDisplayMode.SHOW` will show the search bar,
:attr:`SearchDisplayMode.HIDE` will hide the search bar, and :attr:`SearchDisplayMode.DEFAULT` will
use the default value configured by the user and system settings.
Returns:
a new tree table with the layout hints set
Raises:
DHError
"""
try:
_j_layout_hint_builder = _JLayoutHintBuilder.get()

if front is not None:
_j_layout_hint_builder.atFront(to_sequence(front))

if back is not None:
_j_layout_hint_builder.atBack(to_sequence(back))

if freeze is not None:
_j_layout_hint_builder.freeze(to_sequence(freeze))

if hide is not None:
_j_layout_hint_builder.hide(to_sequence(hide))

if column_groups is not None:
for group in column_groups:
_j_layout_hint_builder.columnGroup(group.get("name"), j_array_list(group.get("children")),
group.get("color", ""))

if search_display_mode is not None:
_j_layout_hint_builder.setSearchBarAccess(search_display_mode.value)

except Exception as e:
raise DHError(e, "failed to create layout hints") from e

try:
return TreeTable(j_tree_table=self.j_tree_table.setLayoutHints(_j_layout_hint_builder.build()),
id_col=self.id_col, parent_col=self.parent_col)
except Exception as e:
raise DHError(e, "failed to set layout hints on tree table") from e

def _j_py_script_session() -> _JPythonScriptSession:
j_execution_context = _JExecutionContext.getContext()
Expand Down

0 comments on commit 6bff70c

Please sign in to comment.