"Block" row selection on Power Table

Hi All,

I need to block the user from selecting rows on a Power Table. The rows selection will be permitted from a dropdown list only. (es: I have [1,2,3] inside my dropdown component, when I select 1, the row number 1 will be highlighted and so on ). The only option I found to do this, is to disable the Power Table, but doing this, I’m no longer able to change the selected row background color ( Whatever color I set, it always go back to ‘192,192,192’ ).
I tried with the normal Table and everything work as expected ( disable will prevent the user to highlight any rows, but it will highlight the row ( of the right color ) if it is selected from the dropdown list ) but, I need the Power Table’s “configureCell” function which is not present in the normal Table.

Any suggestions?

Cheers,

Hi,

the power table has a proporty named “Row Selection Allowed”, uncheck this property and it should work for you.
For more info see: https://docs.inductiveautomation.com/display/DOC79/Power+Table

Thanks for the replay, but it is not working :’(
By disabling that option, I’m no longer able to select rows in either the cases ( from user and from the dropdown )

You can place a container over your table, set opaque to False so that it’s not visible, and then put “pass” in the container’s mouseReleased event. Make sure the container has the same layout properties so it remains the same size as the table.

That will block mouse clicks from being handled by the table.

2 Likes

I thought about it too, but unfortunately the Power Table must has the vertical scroll bar since it can display several rows :’( :’( :’(

Thanks anyway, I appreciated :slight_smile:

My bad! I got it working with the option you suggested :slight_smile:
Thanks :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

Cool! I was about to post that you can adjust the size of the container so that the user can still interact with the scroll bars and even the headers but not the rows themselves.

If you do that you might want to make sure that your vertical scroll bar is always visible. That will prevent any situations where there is not enough rows to be scrollable and the user can click in the table in the gap where the vertical scroll bar would normally be.

# Put this in the initialize () extension function of the power table
from javax.swing import ScrollPaneConstants
self.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
1 Like

Another idea, make a custom property on your Power Table. For example, with the name ddSelect. The properties ddSelect and SelectedRow have a binding to the SelectedValue of the dropdown.

On the table, you can use the following code in the script area propertyChange.

if event.propertyName == "selectedRow":
	if event.newValue != event.source.ddSelect:
		event.source.selectedRow = event.oldValue

This way, the user can select another row but if the index is different from ddSelect the selection jumps back. This solution may be for the situation where you might need to make changes in the table (i.e. onCellEdited)

1 Like