creating a button menu with predefined queries in dynatable

66 Views Asked by At

I wish to create a set of menu buttons that will perform a Dynatable search using predefined search terms. I haven't found previous examples of this and am trying to hack it from the Querying demo given in the documentation, but am not sure how to make valid code. Here is a stripped down version, searching for the string 'keyword' in a one-column table.

HTML Button:

<div id="button_keyword"><img src="icon.jpg"></div>

HTML Table:

<table id="updateTable">
    <thead>
        <th>
            Article
        </th>
    </thead>

    <tbody>
        <tr>
            <td>first</td>
        </tr>
        <tr>
            <td>second</td>
        </tr>

        <tr>
            <td>third with keyword etc.</td>
        </tr>
    </tbody>
</table>

Jquery:

$(document).ready(function () {
    $('#button_keyword').on('click', function () {


        var value = 'keyword';
        console.log('filtering: ' + value);

        var dynatable = $('#updateTable').dynatable({
            features: {
                paginate: true,
                recordCount: true,
                sorting: false
            },


        }).data('dynatable');


        dynatable.queries.add("Article", value);

        dynatable.process();


    });

});
0

There are 0 best solutions below