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)
To use this workflow in KNIME, download it from the below URL and open it in KNIME:
Download WorkflowDeploy, schedule, execute, and monitor your KNIME workflows locally, in the cloud or on-premises – with our brand new NodePit Runner.
Try NodePit Runner!Do you have feedback, questions, comments about NodePit, want to support this platform, or want your own nodes or workflows listed here as well? Do you think, the search results could be improved or something is missing? Then please get in touch! Alternatively, you can send us an email to mail@nodepit.com.
Please note that this is only about NodePit. We do not provide general support for KNIME — please use the KNIME forums instead.