1375 htmx target table filtering#1383
Merged
phycodurus merged 26 commits into1111-build-htmx-table-widgetfrom Jan 22, 2026
Merged
1375 htmx target table filtering#1383phycodurus merged 26 commits into1111-build-htmx-table-widgetfrom
phycodurus merged 26 commits into1111-build-htmx-table-widgetfrom
Conversation
also add type column to table so we can sort on it later
We re-defining the default ChoiceFilter to add htmx attributes to it's widget. (forms.Select is the default widget, but we have to make it explicite in order to add htmx attributes to it).
this class was mis-named: it's a FilterSet subclass for Targets. Also django_filter defines XXXFilter (e.g. ChoiceFilter) classes which correspond to form fields. TargetFilter would thus be a type of Filter, not a FilterSet. So, TargetFilterSet better reflects what this class actually is.
hx-include of "closest form" collects all the form data from the
TargetFilterSet and sends it to the {% url 'tom_targets:list' %}
as specificed in the target_list.html as query parameters.
Without this only most recently used filter is honored. With this,
all the filters are honored.
the problem at the moment is that this work alone, but doesn not play nicely with the other filters. (We need to honor the request parameters as we construct the db Q's).
We don't need to send an AJAX request for every single keystroke. Wait until they stop/pause typing before sending the request.
The queryset argument is the result of the previous filters in the filter chain. We must furter filter this queryset with queryset.filter(Q), not start over with Target.objects.filter(Q)!
Also, don't propagate the checkbox click to the header or else the header will thing we're trying to sort on that column.
directly. There's no hidden button connected to the form anymore.
The FilterSet change triggers the update to both the table and Aladin. This is an htmx triggered AJAX call that does an out-of-band swap (i.e. the Aladin part of the DOM is "side-loaded" (updated) away from the HTML element that generated the AJAX call).
and refer to it in the <table> element HTMX attributes defined in tables.py. The sorting and pagination AJAX call, which are generated by the <table> element need to know about the request parameters from the <form> element. The id in the <form> ID hx-include in the <table> make that happen.
The hx-boost=True attr on the <table> element is needed so that the sorting and pagination requests are HTMX table-only reloads. For the linkified 'name' table.Column, we need to turn off the hx-boost so that clicking on the name brings up the TargetDetail page as a full page reload.
Since we removed the submit button, need to make these fields submit requests triggered by Return key-up.
We were already "side-loading" the skymap when the table page contents changed, but we weren't loading the exact targets in the table. This does that. We needed to create the object list (called skymap_objects in the context) in the View.get_context_data. This is then specified as the object_list sent to the table and skymap partials.
The Filter subclass instance and their methods remain as examples. We may move this to the documentation.
9bfab07
into
1111-build-htmx-table-widget
4 of 23 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.