• Resolved oscare

    (@oscare)


    I don’t understand how to use the plugin.
    I have a plugin that generates a table from a MySQL query.
    Can I use wp datatables in connection with my plugin?
    If so, where am I supposed to place the codes to generate the datatable?

    Is there a front end to the plugin? I don’t see any.

    If I have a static table, where do I place the code?

    • This topic was modified 8 years, 3 months ago by oscare.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author samsk

    (@samsk)

    This plugin does post-processing on frontend (in browser).
    So once you have some table with specific ID, just use anywhere plugin shortcode with that ID. When viewing affected page, plugin will generate javascript, that will instantiate datatables on given table ID.

    There is no frontend, datatables are too powerfull and complicated for that.

    For static table just add shortcode after that table.

    Example:

    
    <table id="table1">
    <thead>....
    <tbody>....
    </table>
    
    [wp-datatable id="table1"]
      responsive: true
    [/wp-datatable]
    
    Thread Starter oscare

    (@oscare)

    Thank you for the quick response.
    Can use this plugin with a table that is generated from a MySQL query?
    If so, where do I place the code?

    Plugin Author samsk

    (@samsk)

    Not sure what do you mean with ‘table generated from a MySQL query’, if I can not see it, i’cant give you exact advice.

    But, you should be able to use the shortcode anywhere. The javascript init part executed once the document is ready => jQuery().ready()

    Thread Starter oscare

    (@oscare)

    I have a plugin that does this:
    It has a query like $query = ‘SELECT * FROM users’
    That query gives me the results like:
    $result = $wpdb->get_results($query, ARRAY_A);
    With $results I build a table.
    Now, I want to have that table to become a DataTables table.
    Where can I apply the shortcode?
    If the shortcode does not work, then how can I instanciate your plugin?

    Plugin Author samsk

    (@samsk)

    Use the shortcode within somewhere with page or post – I don’t know how your table is included.
    From plugin itself you can always use do_shortcode() function.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘How to use the wp datatable’ is closed to new replies.