Reusable inside a reusable (needed for filtering)

I have a user_table reusable where I have a RG with the users of the app. I want to filter this reusable according to the values in the filter reusable filter_user.

What I do is

  1. insert filter_user in a hidden group in user_table
  2. set custom states for filter_user
  3. in user_table, when DO A SEARCH FOR, filter for filter_user custom states
  4. In the actual page I put both reusables
  5. I expect that when I change the parameters of filter_user, its parameters are changed and thus the RG of user_table to be filtered, but this is not the case.

What am I doing wrong? I read this piece but I don’t think it answers my question

Hello @user28

This video explains filtering in Canvas very thoroughly. Hopefully it helps! :smiley:

So, here is an example of my situation.

We have two reusables: filter and list. Both have the same states (user_name, in this case).

  • In the filter_user I have a workflow: “when the input’s value is changed” → set state of reusable.
  • in the user_table I filter the RG for the user_table’s own user_name state
  • on the page then I put a condition “do when filter’s state is not empty” → set state of user_Table, but this only affects the first instance when I change the value of the input.

So, basically, I still do not have a solution. Can someone help?

Hello @user28

The approach to filtering described in the video is reliable. In my experience using events as filter triggers is not reliable.

Also, your reusables lack the type of content that the event is monitoring for … which in your case is defined as a text (user_name).

Yes, but, from what I understand, the video does not explain how we can transfer custom-state data from reusable to reusable. I.e. it does not explain how to “set state of RE2 when state of RE1 changes”. It just explains how to “send state of RE1 to the main page” which I know how to do, but I do not know the next step: use that state to set the state of RE2. having one reusable inside another does not work either (see edited editor)

or it might be that I am just too confused to understand it :sweat_smile:

Hello @user28

Reusables communicate via 3 ways:

  • custom states
  • url parameters
  • custom events

In your case the relevant ones are the first two. In either one of these you will need to set the state or set a url parameter. And set the search constraint to the chosen one. No need for the event trigger.

I recommend for you to watch the video and focus on how search is constrained and how states or url parameters are passed. If the video does not cover it fully then research how custom states and url parameters work (focusing on how they are passed and “seen”). Even though the video is about how filtering work using Canvas assets, it does a great job at explaining most of the above concepts.

how can I refer to the chosen state in the search constraint? this is the point that I am missing…

Hello @user28

You set the state to the field you want to filter within the search constraint.

This video should be helpful. It covers different techniques and instances where states are used in filtering: