Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of MultiTableMixin with Filtering #953

Open
cdufse opened this issue Jul 3, 2024 · 0 comments
Open

Use of MultiTableMixin with Filtering #953

cdufse opened this issue Jul 3, 2024 · 0 comments

Comments

@cdufse
Copy link

cdufse commented Jul 3, 2024

Hello,

Is it possible to have an evolution of this package django-tables2 for some things that can be very useful.
the goal : display several tables on a same page with all the abilities of the SingleTableMixin table.

class PersonTablesView(MultiTableMixin, TemplateView):
template_name = "multiTable.html"
tables = [
PersonHTMxTable(qs1), => from 1 table of person
CityHTMxTable(qs2), => from 1 table of cities
JobHTMxTable(qs3) => from 1 table of jobs
]
table_pagination = {
"per_page": 5
}

2 cases can be very useful:

  • 1 search bar to filter all the tables,
  • 1 search bar for each table displayed if several tables in a page.

I have this needs but i don't find any workaround to solve these 2 problems.

I use HTMx get request in django to define search bar.

In a single table case I can define this kind of class and it's working

class PersonTablesView(SingleTableMixin, FilterView):
table_class = PersonHTMxTable
queryset = Person.objects.all()
filterset_class = PersonFilter => a new class to filter in person table with field of search bar
paginate_by = 5
template_name = "singleTable.html"

My goal is to have this kind of thing working :

class PersonTablesView(MultiTableMixin, TemplateView, FilterView):
template_name = "multiTable.html"
tables = [
PersonHTMxTable(qs1), => from 1 table of person
CityHTMxTable(qs2), => from 1 table of cities
JobHTMxTable(qs3) => from 1 table of jobs
]
filters = [
PersonFilter, => a new class to filter in person table with field of search bar
CityFilter, => a new class to filter in cities table with field of search bar
JobFilter => a new class to filter in jobs table with field of search bar
]
table_pagination = {
"per_page": 5
}

if the same thing allow to search in the 3 filters or if 3 search things are use for each filters could be possible, using
1 or 3 boxes in html like this :

form hx-get="{% url 'my_request_htmx linking python class' %}" hx-target="div.table-container" hx-swap="outerHTML" hx-indicator=".progress" class="d-flex flex-row align-items-center flex-wrap"> /form

So is it possible to have a such evolution in the django-tables2 package ?
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant