My solution for filtering by the belongsTo
relation
#2210
rajabilal555
started this conversation in
Show and tell
Replies: 2 comments
-
Hello, as a workaround you can override TD.php and modify buildFilterString() to looks like
Or if you use custom filter just adjust value() function as you want. |
Beta Was this translation helpful? Give feedback.
0 replies
-
use TD's filterValue() method for loading the right label for your selected filter. no need to override anything. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since there is no simple way of using the built in
HttpFilter
to filter relations, I have come up with a way to filter at least the basicbelongsTo
relations with out defining custom Filter classes...Here is the basic code for it.
the
TD::make
's name parameter should be same as the column in the db (in this casesub_subject_id
).If you have not too many Records in the "sub_subject" table like this example, then you can use the following:
Preview:

If you want Lazy Loaded dropdown and have a lot of records in the table then you can use the following:
The only problem with the Relation Field approach is that it will show the id instead of the name when filtering...

Preview:
I have not yet come up with a work around for the Relation field Filter tag, maybe some one can help with that... ?
Caveats: If you have a lot of Records you will probably have to go the Custom Filter Route as the current solution doesn't look as good.
Beta Was this translation helpful? Give feedback.
All reactions