Filters - product filtration
Hello! I have a database structure in Ninox where I create filters for products. The structure looks like this:
Filters
Table — stores filters like "Gender", "Color", "Season", etc.Filter_Name
Subtable in theFilters
Table — contains the filter name (for example, "Gender") and a relation to categories.Categories
Subtable inFilter_Name
— stores categories for each filter, for example, "Male", "Female", "Unisex".
I need a dynamic field on the product page to first display a list of all filters, and then, when I select a filter, automatically display the associated categories from the subtable.
I tried using the following formula:
let selectedFilter := this.Filter;
let categories := select Filter_Name where Filter_Name.Filter = selectedFilter;
categories.Category_Name
However, I am getting an error "Field not found" or "Not found". I can't figure out how to correctly set up the relationship between the Filter_Name
subtable and the main Filters
table to correctly display the categories.
I have attached the database to this email, so you can take a look at the structure and relationships. It might be easier to understand and help with the issue if you check it directly.
I would appreciate any help or suggestions!
8 replies
-
Here are my suggestions:
In the Products table:
1: change the code for Filter dynamic choice to:
record(Filters,1).Filter_Name
It looks like Filters is a dashboard or the beginning of a modular table. So if you only have 1 record then you can use the record() command.
2: change the Categories dynamic multi choice field to:
let selFilter := record(Filter_Name,number(Filter)); selFilter.Categories
Since each record in Filter_Name is linked to Categories you can use that relationship to create you dynamic fields with the use of the record() command again.
With dynamic fields, the record() command becomes your best friend.
Nice and simple code with no selects.
-
You should be aware that dynamic choice fields selections are "remembered" by Ninox even if you change the selection. If you select Gender under Filter and then select Male. Then you switch to Seasons and select Winter and Spring. Male will still be selected but not shown. You can see this by creating a new formula field and put the dynamic choice field name in it and it will show you the selections made.
Since Filter is a single choice field, you only care about the categories that match the filter. That means you should put in the Trigger after update of Filter:
Categories := null
So everytime you switch Filter, you clear out Categories and don't have carry over.
-
Hi,
I don't know if this is relevant to the post, but you can download a database with "filter examples" in the German forum:
https://forum.ninox.de/t/m1y6pl5/optimieren-von-mehrfach-filter-in-ansichten-eines-dashboards
Content aside
- Status Answered
- 8 days agoLast active
- 8Replies
- 48Views
-
3
Following