Filter lookup values by other field

Is it possible to filter a lookup field by another lookup filed value?
For example, I have a entry form with projects and categories.
Categories is depended on the selected project.

tx

Hi Bart,

Nope. Not possible at the moment if both fields are part of the form. Is it possible to move the project outside of the form? If yes could then handle its Change event and filter the categories.

If not we can expose a Change event of the form too which would allow you to do the same - filter the categories.

Cascading lookups is a common pattern for data entry. I’d say exposing change events for all controls in a form would be useful for plenty of cases. Say immediate input validatation for example.

@joshbooker I am afraid this won’t be possible as we don’t know what controls a form contains beforehand. We can expose a Change event which will tell what field changed. One can act as needed from there using the Condition property. At some point the UI should be a lot better for cases like this.

You are absolutely right that cascading combos are a common scenario. We will think of a way to make it easier to define the relationships between them.

One of the latest additions to Radzen (nested component designer) allows us to implement a new type of Form component which supports arbitrary content. This in turn would allow for cascading dropdowns done in a way similar to LightSwitch - keep the selection of the parent dropdown in a page property (data item in LS terms if I am not mistaken) and use it to filter the child dropdown. What do you guys think?

@korchev,

Could you kindly give some more details of this process? I am trying to create Cascading DropDowns in one Form, for a task Category and Subcategory.

I followed the method mentioned here Best way to interact (hide/disable/enable/fill programmatically) with client forms fields/components to set the Visibility (the values are hard-coded right now but I hope that can be refined later).

To filter the Subcategory Lookup by ParentCategoryID matching the value of the CategoryID Dropdown, I first tried setting the Page Load of getTaskSubcategories with $filter ParentCategoryID eq ${myForm.CategoryID} and that completely broke the Visibility test (the field never displayed).

Then I tried adding a Set Parameter to the Change event of the form and named it SelectedCategoryID with a value of ${myForm.CategoryID} and setting the Page Load of getTaskSubcategories with $filter ParentCategoryID eq ${SelectedCategoryID} but that didn’t work either.

Any help would be greatly appreciated.
Chadrick

Hi @Chadrick,

Does this blog post help a bit? If not you can paste the JSON of that page here so we can check it.

Hey @korchev,

Oh I didn't notice that blog post. Unfortunately, it doesn't seem to be quite the same thing because it takes three standalone DropDowns and modifies the result of a Form. It looks like the mechanics are a little bit different in my case, because I am trying to have one DropDown in a Form filter another DropDown within the same Form.

I've tried several variations but nothing seems to work. For the moment, I took out the Visibility check with the Set Property of myForm for the moment because that seems to get broken with my guesses of $filter.

My guesses for the problem are either that Page Load Invoke event is loading all of the Subcategories initially and they're not being filtered after a Category DropDown in selected or that maybe the $filter ParentCategoryID eq ${event.CategoryID} in the Form Change event isn't the right string to get the current value selected in form0.CategoryID.

I wasn't sure which part of the JSON should be pasted so I just zipped it instead.
add-task-test.zip (1.3 KB)

Thanks so much!

Hi Chadrick,

The Change event of the form has two properties - property (name of the property that changed) and value (the new value).

You could try changing the $filter to ParentCategoryID eq ${event.value} also set the Condition to ${event.property} == 'CategoryID'. By doing this the filter will execute only when the CategoryID property changes.

Best,
Atanas

1 Like

That works beautifully, thank you. Now that makes sense how there is one Change event for an entire form, because they’re separated out with Property and the CategoryID can be referred to with ${event.value}. Thanks again!