Reset Dropdown filter without resetting power table data

Hello Everyone,

I have an power table on my screen. I am selecting the top five-row from SQL server and showing on my ignition screen on power table where I am saying in SQL query binding
“SELECT Top 5 * FROM dprint
where Part_Number = {Root Container.Power Table.Partnumber}
and Operation_Number = {Root Container.Power Table.OperationNumber}.”
I have two a dropdown for Operation_Number and Part_Number where I am saying accordingly in SQL query binding
“SELECT DISTINCT Operation_Number FROM dprint.”
“SELECT DISTINCT Part_Number FROM dprint”
Now I made a button to reset both dropdown where I said in scripting
"event.source.parent.getComponent(‘Dropdown’).selectedValue = -1
event.source.parent.getComponent(‘Dropdown 1’).selectedValue = -1’

now when I am pressing this reset button dropdown to get reset successfully but it also reset my power table where I am showing my top 5 rows. I don’t want table being reset with dropdown but I want it to show last top 5 rows without any dropdown filter. Can anyone help me with this? That would be highly appreciated.

Create two custom properties on your power table, one for part number and one for operation number. Bind your query parameters to your custom properties, not the drop down selections. Then script your drop downs to only write to the custom properties when selectedValue != -1 in the propertyChange event. For example,

if event.propertyName == 'selectedValue':
   selected = event.source.selectedValue
   if selected != -1:
      event.source.getComponent('powerTable').partNumb = selected
1 Like

I did add two custom properties. I tried to bind custom properties with SQL query saying
SELECT DISTINCT Operation_Number from dprint
and table is getting broken. So now in OperationNumber custom proprties I did expression binding saying
“’” + {Root Container.Dropdown 1.selectedLabel} + “’”
and in PartNumber custom properties I did expression binding saying
“’” + {Root Container.Dropdown.selectedStringValue} + “’”

and in OperationNumber dropdown I did scripting

if event.propertyName == ‘selectedValue’:
selected = event.source.selectedValue
if selected != -1:
event.source.parent.getComponent(‘Power Table’).OperationNumber = selected

likewise in PartNumber. Still, when I press reset dropdown it is resetting my power table.

Please format code by encapsulating it with three back quotes in front and behind. The single back quote is above the tab key.

Do not bind the selection of the drop down to the custom properties, that will defeat the purpose. First, get your drop downs to write to the custom properties only when there is a selection. Once you get that working, then use the custom properties in the query.

Make sure that the code I provided you with has proper indentation so it looks like what I posted. Whitespace matters in python/jython. Your Code should look like this

if event.propertyName == ‘selectedValue’:
	selected = event.source.selectedValue
	if selected != -1:
		event.source.parent.getComponent(‘Power Table’).OperationNumber = selected

Once you get this to write to the custom property only when selection is not -1, then do the query like so

SELECT DISTINCT Operation_Number 
FROM dprint
WHERE Operation_Number = {Root Container.Power Table.Partnumber}

I’ve tested all of the above and it does work