Icon

Generic_​JavaScript_​View_​Selection_​Example

Generic JavaScript View Custom Selection Example

This example by @DanielBog (hub.knime.com/DanielBog) shows how to use the 'knimeService' library to create a custom view where the selection event is propagated to a standard view node of KNIME.

Interactive Generic JavaScript Views — Functionality (dataversity.net/from-a-for-analytics-to-z-for-zika-virus/)

Here, we briefly describe the functionality that helped us to create our interactive generic JavaScript views where the user was able to filter and select the data (for details, please have a look into the full source code in the example workflow). Note that you can use this information and apply it to many different scenarios — to retrieve, select, and filter data.

1. Do you have data available at the input port? How can the data be accessed and retrieved?

knimeDataTable.getColumnNames() — accesses the data and retrieves the column names in a string array, with knimeDataTable being a global JavaScript object that is created and populated automatically
knimeDataTable.getColumn(columnID) — accesses and retrieves an array of all values contained in the column with the given ID (see node description for the details and methods)

2. How can you select and filter data?

knimeService is a second global object that enables you to do this, i.e., support selection and filtering in your view

3. To register a subscriber to the selection events, call the following method:

knimeService.subscribeToSelection(tableId, callback)

4. You can also subscribe to a filter event through:

knimeService.subscribeToFilter(tableId, callback)

5. A callback is the function to be called when a selection or filter event occurs:

filterChanged = function(data) { […] } where “data” is an object that contains information about the currently applied filter

6. To unsubscribe from a filter or selection, call:

knimeService.unsubscribeFilter/Selection(tableId, callback).

7. To change the selection, use any of these three convenient methods:

knimeService.addRowsToSelection(tableId, rows, callback)
knimeService.removeRowsFromSelection(tableId, rows, callback)
knimeService.setSelectedRows(tableId, selectedRows, callback)

Right clickComponent > OpenTable Creator Component Color Manager Scatter Plot Right clickComponent > OpenTable Creator Component Color Manager Scatter Plot

Nodes

Extensions

Links