I have a view with two buttons, and a table. I'd like to change the named query the table is bound to depending on which button is clicked. I've been searching the docs and forums but have not been able to find a solution.
If this is possible, how would I go about it?
Thanks,
Mike
Hello,
You could create two custom properties on your view and bind them to each of your two named queries. Then in your button event script set the table data to the proper custom property.
Frank
2 Likes
I do something similar based on a drop down.
I’m not at my work computer so can’t give examples but as a high level…
You can create a custom property on the table, or a session property depending which road you want to take and bind it to the table data.
On the button action performed, create a script to call the named query and write the result to the custom property.
Depending on what your query is, you can possibly use the same named query and just pass different parameters. It’s amazing how many uses you can make out of the same query by passing parameters.
Thanks Frank, that works well!
To write the resulting data set to the table, would that be setting the table custom property to an array, then looping through the data to populate the array?
I do it different to Frank but same result.
On the button I have the following example code. I've cut out the custom property part as you can write the result straight to the table data.
# Create a Python dictionary of parameters to pass.
params = {"param1":"my string", "param2":10}
# Query Path.
path = "Query/MyQuery"
# Run the Query
ds = system.db.runNamedQuery(path, params)
# Send results to table
Table.props.data = ds
Haven't tried this but you can do it a similar way using Franks Method.
On the button..
ds = "path to custom property that has your named query result"
Table.props.data = ds