Use this file to discover all available pages before exploring further.
Parameter option for number range parameters that can vary based on selection of another parameter.This class can be imported from the squirrels.parameter_options or the squirrels module.
Maximum selectable value for both lower and upper values. Can be provided as a Decimal, int, float, or string representation of a number.Must be greater than or equal to min_value.
Increment or step value for the number range input. Must fit evenly between min_value and max_value. Can be provided as a Decimal, int, float, or string representation of a number.Must fit evenly between min_value and max_value. Increment must be specified if the difference is not divisible by 1.
Default lower value for this option. Must be selectable based on min_value, max_value, and increment. Can be provided as a Decimal, int, float, string representation of a number, or None. If None, defaults to min_value.
Default upper value for this option. Must be selectable based on min_value, max_value, and increment. Can be provided as a Decimal, int, float, string representation of a number, or None. If None, defaults to max_value.Must be greater than or equal to default_lower_value.
User group(s) this option is visible for. Only applies if user_attribute is provided to the factory method create_with_options associated to the NumberRangeParameter.
Parent option id(s) that must be selected for this option to be visible. Only applies if parent_name is provided to the factory method create_with_options associated to the NumberRangeParameter.
A NumberRangeParameterOption object is created in the pyconfigs/parameters.py file. It must be created in a function decorated with the create_with_options factory method from NumberRangeParameter.
Setting up cascading parameters with varying number ranges
This example shows how to create number range options that change their constraints based on the selection of a parent parameter (e.g., different product categories with different price ranges).
# Parent parameter for product category@p.SingleSelectParameter.create_with_options( name="product_category", label="Product Category", description="Category of products")def product_category_options(): return [ po.SelectParameterOption(id="electronics", label="Electronics"), po.SelectParameterOption(id="furniture", label="Furniture"), ]# Child number range parameter with ranges that vary by category@p.NumberRangeParameter.create_with_options( name="price_range", label="Price Range", description="Price range based on product category", parent_name="product_category" # Name of the parent parameter above)def price_range_options(): return [ po.NumberRangeParameterOption( min_value=0, max_value=2000, increment=10, default_lower_value=50, default_upper_value=500, parent_option_ids="electronics" # Only applies when "electronics" is selected ), po.NumberRangeParameterOption( min_value=0, max_value=10000, increment=10, default_lower_value=100, default_upper_value=1000, parent_option_ids="furniture" # Only applies when "furniture" is selected ) ]
This example shows how to provide different value range constraints based on user access levels using the user_groups parameter.
@p.NumberRangeParameter.create_with_options( name="salary_range", label="Salary Range", description="Salary range for search", user_attribute="access_level")def salary_range_options(): return [ po.NumberRangeParameterOption( min_value=20000, max_value=80000, increment=1000, default_lower_value=30000, default_upper_value=60000, user_groups=["member"] # Members see limited salary range ), po.NumberRangeParameterOption( min_value=20000, max_value=500000, increment=1000, default_lower_value=30000, default_upper_value=100000, user_groups=["admin"] # Admins see full salary range ) ]
If custom user fields are defined in pyconfigs/user.py, then they can be used to restrict value range constraints as well. To do so, the user_attribute argument must be prefixed with custom_fields..
@p.NumberRangeParameter.create_with_options( name="commission_range", label="Commission Range", description="Commission range as percentage", user_attribute="custom_fields.department")def commission_range_options(): return [ po.NumberRangeParameterOption( min_value=0, max_value=10, default_lower_value=1, default_upper_value=5, user_groups=["sales"] # Sales team sees standard commission range ), po.NumberRangeParameterOption( min_value=0, max_value=50, default_lower_value=0, default_upper_value=15, user_groups=["executive"] # Executives see full commission range ) ]