Perspective Dropdown component - not accessing last item on list

Good Day All,

I'm seeing a weird behavior using the dropdown component in Perspective which is probably entirely my fault but I don't know why.

I have a table component, with one of the columns is a product code. If I double click on the row a popup appears with a dropdown box giving me a chance to change the product code.

The dropdown box options property it bound to a named query which grabs the list of products from the db. It only returns a single column of data which is all the product codes. That all seems to work just fine.

When I call the popup, I pass it the product code from the row selected on the table, and I stuff the current product code into the value prop of the dropdown box so the user has the starting point (i.e. "this is what's selected now").

This works fine on all the product codes up until the last one in the list. When I try to stuff in that value, the box reverts to the placeholder text and won't take.

Even if I try this in the designer in preview mode, I can type any other product code I want into the value prop and the box will display it EXCEPT for the code that's last on the list.

Anyone have any thoughts on this?

Thanks much

That smells like an indexation error.
A few things come to mind, but you'll have to be more specific: Show us how you're doing this. Code and all.

1 Like

So the binding on the dropdown box options looks like this:

And the code I have tied to the popup that sets the value prop looks like this:

	# Now set the dropdown to what the current product is
	self.getChild("root").getChild("cbo_Product").props.value = self.params.Product

This works for all but the last item on the list (unless being the last item is a red herring and it's something else)

how do you open the popup and pass the parameter ?

This is my code on the onRowDoubleClick event of the table:

	# Grab the underlaying data from the row selected
	myTank = self.props.selection.data[0].TankName
	myProduct = self.props.selection.data[0].Product
	myGloss = self.props.selection.data[0].HighGloss
	
	# Set the title & popup path
	myTitle = 'Edit Product'
	myPopup = 'PopUps/EditProduct_Popup'
	
	# Now call popup	
	system.perspective.openPopup("myPopupId",myPopup, params = {'Tank':myTank, 'Product':myProduct, 'Gloss':myGloss }, title = myTitle, modal = True, )

I can't see anything weird :X
The only thing I'd change is what I assume is a startup script on the popup and replace it with a binding - you can just bind the dropdown's value to the parameter.

Let's take a look at the data then !
I guess the first step is making sure the product actually matches one in the option list, and that what's passed is actually what you think it is.
You can either add a label to the popup to display the parameter directly, use a logger or a console print, to show the parameter's value.
Can you possibly share some sample data ?

I just tried making an example, and it works fine, except for one thing completely different from your issue:
I can't get the clicks on the table's rows to register... Only on the header and footer ! What the hell is going on ?

But aside from that, using the same logic you used (except for the binding on the dropdown's value), it works just fine, I just need to select a row then click/double click on the header or footer, and the popup open just the correct value, even for the last row.

I found the issue - the last item coincidentally had a space at the end in the db table. So for example instead of "BARLEY" is was in the table as "BARLEY ". So when I pulled the product name out of the PLC, and sent it to the dropdown, the dropdown wouldn't display it because it technically didn't match any item in the list.

I figured this out in preview mode, I typed in different values of product into the value filed and could see it change, but when I entered BOB it didn't display so it got me thinking maybe a spelling error or a 0 instead of a O and then I tried it with a space at the end and bam!

SO - I fixed the db table and now all works as should. The fact that it was the last item on the list was coincidental. I should probably put some code in to prevent that issue from happening again just in case there are others in the db table.

Thanks for taking the time to look into this. It really helps to be able to bounce things around on the forum!

1 Like

You can mark your own post as "Solution" so it's marked as solved on the main index.