How to design perspective dropdown property


I have design a dropdown list, in upside picture the right side show on the label , and the left side line become the dropdown value.

when this mode in vision, I can get the both data from selectedvalue and selectedstringvalue this two components.

but in perspective, I can only find the left line in prop.value , is there some solution can make it similar like vision two value can be get in the property?

You can construct an array like this in a transform script, where value is an object:

	returnData = []
	for x in range(value.getRowCount()):
		returnData.append({"label":value.getValueAt(x,1),"value":{"WareHouse":value.getValueAt(x,0),"ToPlace":value.getValueAt(x,1)}})
	return returnData
2 Likes

Basically you have 2 options, if you are not interested in the int value you just need to filter in the String column you want.

  1. Manipulate the options dataset

Use a script transform in your options property:

And when ever you select an option you will see the string value
image

  1. Create you own property,
    If you need the int value for whatever reason, you can create your own property stringvalue.
    Use a property binding using the prop.value and apply a script transform.

the script in the transform is:

	options = self.props.options
	if type(value).__name__ == 'JsonifiableArrayList':
		stringvalue = []
		for v in value:
			strvalue = None
			for r in range(options.rowCount):
				if options.getValueAt(r,0) == v:
					strvalue = options.getValueAt(r,1)
					break
			stringvalue.append(strvalue)
	else:
		stringvalue = None
		if value is not None:
			for r in range(options.rowCount):
				if options.getValueAt(r,0) == value:
					stringvalue = options.getValueAt(r,1)
					break
	return stringvalue

it works , thanks a lot

image
current status is like this, only 1 value can be read in the props
image
what I want is this picture, two value can be binding in the property, that can be realize by victordcq code

1 Like

Hi, is it possible to have 2 items in the dropdown, I want in such a way that we do like in vision as list in dropdown, so we will see 2 columns in there, likewise is it possible to have 2 columns like label and value both in the dropdown UI, when we click on the dropdown.

No, not possible, it will only display a single string from the label property.

You'll have to format the labels string to include your second column

There is an ideas post for the ability to make drop-down elements into embedded views. This would give the desired affect you were looking for