Skip to content

Sort more then one table separately #11

@s229988

Description

@s229988

Sorry for the chaos with the close/reopen ...
I have a template with more tables with the same headers and i want to sort each table separately. How can I implement that not each anchor/header sorts all 4 tables?

{% extends 'base.html' %}

{% load sorting_tags %}

{% block body %}


<div class="container">
    <h1>Pending</h1>
    {% autosort articles_pending %}
    <table class="table">
        <thead>
            <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            {% for articles_pending in articles_pending %}
            <tr>
                <td>{{ articles_pending.production_nr }}</td>
                <td>{{ articles_pending.article_nr }}</td>
                <td>{{ articles_pending.article_name }}</td>
                <td>{{ articles_pending.amount }}</td>
                <td>{{ articles_pending.price_offer|floatformat:2 }} €</td>
                <td>{{ articles_pending.create_date }}</td>
                <td>{{ articles_pending.start_date }}</td>
                <td>{{ articles_pending.end_date }}</td>
                <td>{{ articles_pending.status }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
     <h1>In production</h1>
    {% autosort articles_inproduction %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_inproduction in articles_inproduction %}
                <tr>
                  <td>{{ articles_inproduction.production_nr }}</td>
                  <td>{{ articles_inproduction.article_nr }}</td>
                  <td>{{ articles_inproduction.article_name }}</td>
                  <td>{{ articles_inproduction.amount }}</td>
                  <td>{{ articles_inproduction.price_offer|floatformat:2 }} €</td>
                  <td>{{ articles_inproduction.create_date }}</td>
                  <td>{{ articles_inproduction.start_date }}</td>
                  <td>{{ articles_inproduction.end_date }}</td>
                  <td>{{ articles_inproduction.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
        <h1>Done</h1>
    {% autosort articles_done %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_done in articles_done %}
                <tr>
                  <td>{{ articles_done.production_nr }}</td>
                  <td>{{ articles_done.article_nr }}</td>
                  <td>{{ articles_done.article_name }}</td>
                  <td>{{ articles_done.amount }}</td>
                  <td>{{ articles_done.price_offer|floatformat:2 }} €</td>
                  <td>{{ articles_done.create_date }}</td>
                  <td>{{ articles_done.start_date }}</td>
                  <td>{{ articles_done.end_date }}</td>
                  <td>{{ articles_done.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
     <h1>No match</h1>
    {% autosort articles_nomatch %}
    <table class="table">
        <thead>
              <tr>
                <th>{% anchor production_nr _("Production #") %}</th>
                <th>{% anchor article_nr _("Article #") %}</th>
                <th>{% anchor article_name _("Article name") %}</th>
                <th>{% anchor amount _("Amount") %}</th>
                <th>{% anchor price_offer _("Price") %}</th>
                <th>{% anchor create_date _("Create date") %}</th>
                <th>{% anchor start_date _("Target start date") %}</th>
                <th>{% anchor end_date _("Target end date") %}</th>
                <th>Status</th>
              </tr>
            </thead>
            <tbody>
              {% for articles_nomatch in articles_nomatch %}
                <tr>
                  <td>{{ articles_nomatch.production_nr }}</td>
                  <td>{{ articles_nomatch.article_nr }}</td>
                  <td>{{ articles_nomatch.article_name }}</td>
                  <td>{{ articles_nomatch.amount }}</td>
                  <td>
                      <form action="{% url 'change_price' order_id=articles_nomatch.pk article_id=articles_nomatch.article_id %}" method="post">{% csrf_token %}
                      <input type="number" name=new_price id="new_price" step="0.01" value="{{ articles_nomatch.price_offer|floatformat:2 }}" style="width: 5em;" />
                      <input class="btn btn-success myButton" type="submit" value="Save"/>
                      </form>
                  </td>
                  <!--<td>{{ articles_nomatch.price_offer|floatformat:2 }} € <a class="glyphicon glyphicon-edit"></a><a class="glyphicon glyphicon-ok"></a></td>-->
                  <td>{{ articles_nomatch.create_date }}</td>
                  <td>{{ articles_nomatch.start_date }}</td>
                  <td>{{ articles_nomatch.end_date }}</td>
                  <td>{{ articles_nomatch.status }}</td>
                </tr>
              {% endfor %}
            </tbody>
    </table>
</div>

{% endblock %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions