I have a perspective view for reporting, that uses several multi select drop downs to pass parameters to a report. I would like to be able to create a button that selects all items in a particular drop down. Thus far i haven’t been able get it to work, any suggestions would be much appreciated.
You want to make a list of all of the values that the dropdown has as options, then set the props.value property of the dropdown to that list. something like this worked for me:
options = self.getSibling("Dropdown").props.options
values = [option['value'] for option in options]
self.getSibling("Dropdown").props.value = values
this is assuming that you are using an array of objects for your dropdown options. If you are using a dataset, or something else let me know and I can edit the code to work for that.
Thank you! I am using a dataset generated by a query for the options.
Okay, so you need to modify my code slightly to get the value from the dataset rather than from a dictionary:
options = self.getSibling("Dropdown").props.options
values = [options.getValueAt(i, 'value') for i in range(options.getRowCount())]
self.getSibling("Dropdown").props.value = values
The above code is assuming that the value column of your dropdown dataset is named ‘value’. if it is named something else, make sure you change the options.getValueAt
call to use your column name. Also, make sure your dropdown has the multiSelect property set to true
That is perfect, thank you. One of my drop downs has over 200 options, which doesn't work. There must be a character limitation somewhere, it will work with up to 160 options selected.
That’s odd. I made a dropdown with 200 options, and I was able to select them all using a button with that script. When you say it doesn’t work, what do you mean? What happens when you hit the button?
This is what i get on the report viewer component:
“Enter a valid report in the “source” property in the Property Editor to display the report.”
My options are strings, if i select them all it comes to 5,382 characters. I many need to look into modifying my base query to include a like ‘%’ when passed a parameter.
Oh I see. I am not familiar with that component. I thought you meant the dropdown wasn’t able to have 200 options selected. Good luck figuring it out