0

Morning all,

New to datatables, python and jquery so bear with me. I'm trying to get a datatables table imported through python to filter on column results on a button click. I've searched for answers to this already, but most seem to be geared around text filters or selector filters, which isn't exactly what I'm looking for.

Here's a JSFiddle mockup I created:

https://jsfiddle.net/4m5up9bx/2/

    <div align=center><a href="a" class="navy small btn">Mapping Tools</a>
    <a href="b" class="teal small btn">Charting Tools</a>
    <a href="c" class="green small btn">Analyzing Data</a>
    <a href="d" class="yellow small btn">Programming Tools</a>
    <a href="e" class="orange small btn">Other Data Tools</a></div>


    <table id="tools" border=1 cellpadding=7>
        <thead>
        <th>Program</th>
        <th>Type</th>
        <th>Skill Level</th>
        <th>Website</th>


    </thead>
    <tbody>
        <tr>
            {% for obj in object_list %}

            <td><a href="{{ obj.id }}/">{{ obj.program }}</a></td>
            <td>{{ obj.type }}</td>
            <td>{{ obj.skill_level }}</td>
            <td><a href="{{ obj.website }}/">{{ obj.website }}</a></td>
            </tr>
        {% endfor %}
    </tbody>
    </table>

Doesn't quite work without the python but will give you the gist. To start, the table displays all results, as you might expect. Essentially, all I want to do is allow for someone to click one of the buttons and have the table filter if the column "Type" equals a set text value.

I have a field ('Type') which includes five set values: Mapping, Charts, Data Analysis, Programming and Other.

So, if someone were to click the Mapping Tools button, I'd like the datatable to filter only to results where {{obj.type}} = "Mapping" Any thoughts?

1 Answer 1

0

you may use server-side datatable. where you can pass custom parameter for your object (ie, mapping, charts)to an ajax request and fetch json data and show on the datatable. or you can check "Generated content for a column"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.