We observed that the above template uses knimeService to publish selection events. I could not find any documentation on KNIME website regarding knimeService except this knime blog - https://www.knime.com/blog/from-a-for-analytics-to-z-for-zika-virus .
Is there any documentation available on how to use knimeService and what other functions/features does it provide ?
Thank’s for your question. At this time, the knimeService global variable isn’t fully documented. That being said, here is some commonly used functionality that’s worth mentioning:
knimeService.isInteractivityAvailable() - this will return true if the view is part of a composite view with other views (and able to pub/sub events) or false if the view is a single node view.
knimeService.setWarningMessage(msg, id) /
knimeService.clearAllWarningMessages() - these methods are available to manipulate the native KNIME warning message (usually seen in the upper right hand corner as a ‘!’ icon)
knimeService.setSelectedRows(tableId, selection, callback) /
knimeService.addRowsToSelection(tableId, selection, callback) /
knimeService.subscribeToSelection(tableId, callback) - registers the view with any selection events published in a composite view for the provided tableId (provided by the knimeDataTable). The callback function receives an event Object which contains the update information.
knimeService.unsubscribeSelection(tableId, callback) - deregisters the view from reacting to selection events when they are published in the composite view. Same parameters as in the sub method.
knimeService.subscribeToFilter(tableId, callback, filterElement) - registers the view to receive published filter events in the same composite view. TableId is the same as for selection and the callback function receives an event Object with the updated filter information (published by the Interactive Range Slider Filter Widget, or the Interactive Value Filter Widget) and the filterElement parameter can be retrieved using the knimeDataTable.getFilterIds() method.
knimeService.unsubscribeFilter(tableId, callback) - deregisters the view from reacting to filter events.
knimeService.isRowSelected(tableId, rowId) - returns true if the rowId provided is currently selected, false if not.
knimeService.getAllRowsForSelection(tableId) - returns the full global set of currently selected rowIds.
knimeService.addMenuItem(title, icon, element, path, flags) - adds a control element to the native KNIME dropdown menu in the upper right hand corner of the view. Title is the label assigned to the menu item, icon is the String name of an icon from the Font Awesome V4.7.0 library, element is the actual element created with one of the Menu Items methods below, path is an optional parameter (passing null is fine), flags can be: knimeService.CLOSE, .OK, .CANCEL, .LINK, .SMALL_ICON or undefined/null.
knimeService.allowFullscreen() - creates a native KNIME ‘fullscreen’ control button in the upper right hand corner of the view if it is in a composite view which allows the user to enter fullscreen mode when it is clicked.
knimeService.addButton(id, icon, title, callback) - creates a native KNIME control button in the upper right hand corner of the view provided: (id) the HTML id, (icon) the String name of an icon from the Font Awesome V4.7.0 library, (title) the hover text for the button and (callback) the function to fire when the button is pressed.
knimeService.addNavSpacer - adds space between the most recently added button and the next button to be added with the .addButton() method.
(all return elements to be added to the native KNIME dropdown menu using the addMenuItem method)
- knimeService.createMenuTextField(id, initialValue, callback, immediate)
- knimeService.createMenuNumberField(id, initialValue, minimum, maximum, step, callback, immediate)
- knimeService.createMenuSelect(id, initialValue, options, callback)
- knimeService.createMenuCheckbox(id, initialState, callback, value)
- knimeService.createMenuRadioButton(id, name, value, callback)
- knimeService.createInlineMenuRadioButtons(id, name, initialValue, options, callback)
knimeService.addMenuDivider() - does not return an element, but adds a horizontal bar to space the vertical distribution of menu items in the KNIME dropdown.
knimeService.log(message) - logs message
knimeService.logError(err) - logs error
knimeService.inlineSvgStyles(svg) - when provided an SVG element, this method applys all stylesheets available in the scope and context of the view as inline styles if possible.
Hello @blaney ,
Thank you very much for the details.
I could use selection events publish/subscribe api from knimeService to create interactive exploration view and it works perfect.
I was wondering if it is possible to publish filter events using knimeService. For some of user experience requirements, we wish to publish filters using custom view(instead of Value Filter). Do you have any suggestions ?
With the existing functionality you can use functionality provided by the
knimeDataTable API to apply the filter to the data table in the view. Check out the source for that API here. Methods like
isRowIncludedInFilter make it really simple to apply the filters matching the existing filter API to the data within a view.
I hope this helps!
knimeService API to implement some custom controls.
This allows you to filter out rows based on the letter in the input field. At the end of the day, the
knimeService API acts as a general Pub/Sub service provider, so once you get the
tableIds matched up, you can create more in depth filters or interactions as needed.
Let me know if you have any questions!
sample_searchable_filter.knwf (460.6 KB)
Hello @blaney ,
Thank you for the example workflow. It works nicely on its own but if I add Table View in same component, it does not filter the Table View.
The custom selection views which publish selection events work with existing knime views like Table View or Scatter Plot view. However custom filter views(including the view you have shared in example workflow) do not appear to work with these knime views. This limits usage of existing knime views with custom filter views. Is my understanding correct?
You’re right in that truly custom filter events like the one in the example will not be registered by existing KNIME visualization nodes. The example I made uses
RowIDs to filter the data in the custom visualization (scatter plot). You can create filter events using the already implemented API which supports
Nominal filter events. In the image below (taken from the
'nominal' and replace the
rowIds key with
maximum along with
type: 'numeric') OR a
values key (for
type: 'nominal'; set equal to an Array of values to filter).
These filter types are supported by existing KNIME visualization nodes, so they should react to published events if they share the same
tableId. Of course, be sure to read the node descriptions of any nodes you use to make sure they support filters .
rowId based filter events- this is functionality we hope to add in the near future. You can simulate the filter in the example by using a nominal filter to filter by letters, so there are ways to achieve the same functionality with existing nodes.
Hope this helps!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.