Perspective drodown selected label

I want to get the selected label from a perspective dropdown. This post helped…

But, if using showClearIcon and then clearing you will get stale data. Are there any better alternatives to getting the selected label?

With a few modifications, that linked script will still do what you want. You just ned to handle the case where the value (empty String) does not match any row of the dataset, and then return an appropriate value.

    data = self.props.options
    value_found = False
	for row in range(data.getRowCount()):
		if (data.getValueAt(row, "value") == self.props.value):
			self.custom.displayvalue = data.getValueAt(row, "label")
            value_found = True
			break
    if not value_found:
        return 'someOtherValue"

Thanks, that’s what I ended up doing. Just making sure that was still the best way to go about it.