Time-Based row Selection in table view and coloring it.

Hi all. I have a table, having 2 columns From_Time & To_Time in 15 minute interval, both having time in HH:mm format and are in string data-type. Now I want to select the row in which the current time can be said to be in between i.e. if current time is 11:07 than the row having from time value as 11:00 and to time as 11:15 should be selected and the color of the selection should be green. For this I have written a java snippet to compare time and populated 1 besides the selected column and than using column expression extracted the particular row Id having 1. Another java snippet to dynamically get row number updated in the custom css. Till this all the process is giving correct result but, when the in table view the the preceding row is selected. i.e. If row Id of row having 1 is 67 than the 66th row is getting colored. Right now I am executing the workflow by adding 1 to the row id selected for coloring but, this not the right practice. Does any one know the cause of the issue? Also I want to run this nodes every 15 minutes how can it be done as the timer method in java snippet is not working with this?

Workflow

Hi @shivani_soni,

to run workflows on a schedule, you need KNIME Server. For KNIME AP a possible workaround is to call the workflow via command line. I haven’t done this yet, but I can point you here:
FAQ | Is there any way to run KNIME in batch mode, i.e. only on command line and without the graphical user interface?
Another solution would be to use this not so reliable construct:
cron
execute every 15min.knwf (21.9 KB)
It has one major drawback though: The Workflow has to be started manually and it cannot be closed. Your PC and KNIME AP have to run 24/7 in order for this to work. It’s really is more a proof-of-concept. Set the value in the Loop End Node to -1 for infinite loops.

The off-by-one problem looks like it has to do with array indexing. Java and JavaScript (the Table View is Java Script) both start arrays at 0 (the right way :wink: ), so we’d probably need your workflow to help with that. Or leave it as it is, since it works as designed.

One more thing, iff you like Node Golf: A Row Filter instead of the Column Expression and Missing Value Nodes should also give you the one desired row. Or, since you’re using Java Snippet Nodes twice: Calculate your Flow Variables directly in the first Java Snippet Node and drop everything else that’s yellow.

Happy New Year, T

1 Like

Thanks for the input. The loop works too. And also modified the workflow based on the input given by you. But I want to update the table view every 15 minutes so that the successive row gets colored based on time. Here is the workflow attached. Maybe it will help understand in a better way.
Table View.knwf (29.0 KB)

If you put your workflow into my loop, it does exactly that. Having it parallel to the delaying node ensures that the Table View will always be in the executed state.

I’m not sure what’s left to do. Can you tell us more about your use case? What do you want to do with the View?


Table View.knwf (48.3 KB)

2 Likes

Thank you so much for your help @Thyme , the loop was working fine I was just misplacing the nodes so. Now I got it correctly.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.