configureEditor on a powertable with multiple conditions

Hello,
I am working on a powertable and trying to configure columns. some have options to create a dropdown, one is a text field. The text field and dropdown worked fine at first, but once I added another with conditions everything went bad and now only shows my first return as options for all editable fields. I need to have multiple options based on a dropdown on the screen, but so far this isn't working. Any help would be appreciated.

Your syntax for additional conditions in if/else if is wrong.
Line 6 needs to be either:
if colName in ('COMP 1 LEVEL', 'COMP 2 LEVEL')
Or
if colName == 'COMP 1 LEVEL' or colName == 'COMP 2 LEVEL'
Similar issues on line 10 and 13 with the and.

What's happening now is the literal string COMP 2 LEVEL on line 6 is evaluating true as the second check, ending up always evaluating that if block as true.

Okay. I believe I understand. For Lines 8-12. Do I need to do something else to get it to switch to the second set of options whenever my dropdown changes string values? right now it is only switching when I go from preview to design mode and then back to preview. The comp level values are holding strong the whole time, so I believe this part is corrected.

Just a note, that

colName in ('POSITION')

is not the same as

colName in 'POSITION'

The first is looking for a string in a sequence and will return false if colName is not 'POSITION'.
The second is looking for a string or substring match in the literal string 'POSITION' so if your column name was any of P,PO, OSI, etc.. it will return true.

1 Like

colName in 'POSITION' (probably) isn't quite right - you're saying "return True if the string POSITION contains my current column name. So a column name of POS, IT, TION, etc would all return true for that check. You probably want a simple equality check there.

As an aside, some of your repetitive options creations can be simplified using list comprehensions:

options = [(it, str(it)) for it in (0, 10, 25, 50, 75, 100)]

options = [(it, str(it)) for it in xrange(18)]

options = enumerate(['0', '1', '2', '1V', '2V', '3V', '4V', '5V', '6V', '7V', '8V', '9V'])
1 Like

I did fix my position string to be ('POSITION') but let me explain a little better. Both sets come up based on my dropdown selection, but if I have 721 chosen first then switch to 722 it will keep 721's list of options. But if I go back and forth from preview to design and then back, it will then switch to 722's list. I am unsure of why. In the program I have to change screens for it to change list options under position after I choose a different option in the dropdown.
721 selected
Screenshot (9)
722 selected- get the same list
Screenshot (7)
press stop to go back to design and then press play to go back to preview and 722's options then finally appear.
Screenshot (8)
In the actual program I have to change screens to get them to show up.

configureEditor doesn't fire all the time - it basically fires once, on initialization of the table. If you want more dynamic option support, you have to get a little more advanced with it. Let me dredge up some old sample code...

I will dig into this. Thank you for the help.