Adjusting Table Layout

Locking Column Order in a Table

Designated columns in Deephaven tables can be "locked" in place at the start or the end of the column order. This enables the query author to ensure a consistent experience for all authorized users of that table. This feature uses the .layoutHints method.

For example, the image below shows a table with eight columns. Four of the columns have a lock icon in the column header. The appearance of that icon means those four columns are locked in place. USym and Timestamp are locked to the left side of the table, and Sym and SecurityType are locked to the right side of the table. Moreover, the tab for the table also presents a "no-write" icon, which means the layout of this table cannot be saved by other users.

Locking columns in starting or ending order in a table is accomplished in the query language by importing the LayoutHintBuilder class and then setting one or more of the following three parameters:

  • atFront() – This method locks one or more columns to the beginning of the table. Column names are used as the argument(s).
  • atEnd() – This method locks one or more columns to the end of the table. Column names are used as the argument(s).
  • savedLayouts() – This parameter impacts users with whom this table is shared.  When set to true, other users can rearrange the non-locked columns and then save their own layout for the specified table.  When set to false, other users can rearrange the non-locked columns, but they cannot save the new column order. When the table is opened again, the column order will revert to the default order specified by the query author.

For example, the table shown in the previous screenshot was created with the following query:

importjava("com.illumon.iris.db.tables.utils.LayoutHintBuilder")
t3=db.t("LearnDeephaven", "StockQuotes").where("Date=`2017-08-25`")
t4=t3.update(java_array("java.lang.String", [])).layoutHints(LayoutHintBuilder.get().atFront("USym","Timestamp").atEnd("Sym", "SecurityType").savedLayouts(False))
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t1=db.t("LearnDeephaven", "StockQuotes").where("Date=`2017-08-25`")
t2=t1.update().layoutHints(LayoutHintBuilder
	.get()
	.atFront("USym","Timestamp")
	.atEnd("Sym", "SecurityType")
	.savedLayouts(false)
	)
  • The first line of the query tells Deephaven to import the LayoutHintBuilder class, which is needed for the query to run properly.
  • The second line of the query generates the t1 table using data from the StockQuotes table in the LearnDeephaven namespace, filtered to August 25, 2017.
  • The third line of the query creates a new instance of the LayoutHintBuilder using the get() method, then creates the table t2, which locks the USym and Timestamp columns to the front of the table, and Sym and SecurityType to the end of the table, and specifies that no changes to the layout can be saved by authorized users upon closing and reopening the table.

To ensure the locked column(s) are applied only on the t2 table, a select, update, updateView or where operation must be included before the .layoutHints() operation in the query. This enables Deephaven to create the t2 table as an individual object before continuing to the next method. 

Hiding Columns

Columns in Deephaven tables can be hidden from view by default in a table, ensuring they are hidden for all users who access that table. This feature uses the .layoutHints method.

from deephaven import *

t1=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`") \
    .layoutHints(LayoutHintBuilder.get().hide("USym","SecurityType","Source"))
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t1=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`")
        .layoutHints(LayoutHintBuilder.get().hide("USym","SecurityType","Source"))

This query generates the t1 table using data from the StockTrades table in the LearnDeephaven namespace, and filters the data to show only data from August 21, 2017. Then, the query applies the layoutHints method, and within that method, creates a new instance of the LayoutHintBuilder and applies the .hide method with the USym, SecurityType, and Source columns as its arguments.

They can be unhidden via the Choose Columns option in the right-click column menu. Selecting Reset Columns will hide them again.

See also Column Name Shortcuts.

Freezing Columns

Designated columns in Deephaven tables can be "frozen" in place on the left side of the table, and will remain in view even when horizontally scrolling through the table. Similar to the "freeze panes" option in spreadsheet software, this feature enables users to keep key columns in view as they read table data.

Deephaven offer two ways to accomplish this: by creating a new LayoutHintsBuilder and using the freeze() method in a query, or through the Deephaven console. The content below demonstrates how to freeze columns using the Deephaven query language.

See: Column Name Shortcuts > Freeze Columns to learn how to implement the Freeze Column option in the GUI.

For example, the image below shows a Deephaven table with only five of the 12 columns in view. The horizontal scrollbar at the bottom of the table begins at the Date column because the USym and Exchange columns are frozen in place and always stay in view:

Freezing columns is accomplished in the query language by importing the LayoutHintBuilder class and using the following syntax:

.freeze("colName")

The table shown in the example above was created with the following query:

LayoutHintBuilder = jpy.get_type("com.illumon.iris.db.tables.utils.LayoutHintBuilder")
t=db.t("LearnDeephaven", "StockTrades")\
   .where("Date=`2017-08-21`")\
   .layoutHints(LayoutHintBuilder\
   .get()\
   .freeze("USym","Exchange"))
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`")
   .layoutHints(LayoutHintBuilder
      .get()
      .freeze("USym","Exchange")
   )
  • The first line of the query tells Deephaven to import the LayoutHintBuilder class, which is needed for the query to run properly.
  • The second line of the query generates the t table, then creates a new instance of the LayoutHintBuilder using the get() method, then within the .freeze method specifies that the USym and Exchange columns should always remain in view.

The frozen columns can be dragged and moved within their space to the left of the table. To unfreeze a column, right-click the column header and select Unfreeze Column from the drop-down list:

This layout hint is compatible with other layout hints, such as Saved Layouts and Autofilters. The following behaviors should be noted when freezing columns via a query:

  • If a column is locked and also frozen by the query language, it cannot be unfrozen by using the right-click method in the GUI. If an unfrozen column is locked using the query language, it cannot be frozen in the GUI.
  • Frozen columns are saved to the workspace and reloaded. If a user specifies columns to freeze via a query and then modifies those columns in the UI, the workspace will load the latest changes rather than what is in the query.
  • Frozen columns can be hidden and restored just like any other column. The Reset Columns option will restore frozen columns to the original state defined in the query.

Note: Freezing columns is not currently supported on Tree Tables.


Last Updated: 16 February 2021 18:07 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved