1

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();


    });

});
dekogames
  • 11
  • 2
  • You should include the output you're getting and how it varies from what you want. – Joundill Apr 02 '20 at 00:23
  • The desired outcome is to have dynatable return only the rows with the defined keyword included ('keyword'). In other words, clicking the button should be the same as entering the keyword in the search field. I'd like to copy that functionality into an onclick link. Currently, there's no result, just the same table as what's given. – dekogames Apr 02 '20 at 17:50

0 Answers0