Support » Plugin: WP Data Access » Adding dataTables Extensions

  • Resolved Judson Mitchell

    (@judsonmitchell)


    Thanks for this fabulous plugin! It’s really well done. I’m trying to add the dataTables buttons extension to my table. Is the only way to do this by editing class-wp-data-access-public.php and registering the script? Or is there a simpler way?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Peter Schulz

    (@peterschulznl)

    Welcome Mitchell! 🙂

    Good question! You need to put that code “somewhere”. I would not advise to add it to a plugin or theme file as your code will be lost when you update. You can create your own plugin file and put it into the plugin directory. At least you don’t need to worry about updates then. Is there anyone else who has a better idea? I hope to launch the Code Manager soon. This is a plugin extension (not free) which solves this issue.

    BTW, here is a discussion about adding the buttons extensio which you might find useful:
    https://wpdataaccess.com/docs/documentation/data-publisher/advanced-settings/#comments

    Hope this helps…

    Best regards,
    Peter

    Plugin Author Peter Schulz

    (@peterschulznl)

    Hi Mitchell,

    Did you succeed in adding a DataTables extension? Can I close this topic?

    Thanks,
    Peter

    Thanks for checking in on this Peter! I think I did basically get it going. I created a new plugin and created this function:

    
    function add_dataTables_buttons(){
       wp_enqueue_style('jquery_datatables_buttons', '//cdn.datatables.net/buttons/1.6.1/css/buttons.dataTables.min.css'); 
    
       wp_enqueue_script( 
          'jquery_datatables_buttons',
          '//cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.js',
          array('jquery','jquery_datatables','jquery_datatables_responsive'),
          false,
          true
       );
    }
    
    add_action( 'plugins_loaded', 'add_dataTables_buttons', 12,0 );
    

    This loads up the css and js for buttons in the right order. Unfortunately, I’ve had to hard code the version because I don’t know how to get your global WPDA::OPTION_WPDA_DATATABLES_VERSION in my function. If you have any suggestions, it would be appreciated.

    Plugin Author Peter Schulz

    (@peterschulznl)

    Hi Mitchell,

    You can add the version number hard coded. That’s okay. The plugin uses a variable, but there is no way to change the value of the variable… 🙈 So effectively, it’s a kind of hard coded variable? 😑 I might make this variable editable some day…

    Best regards,
    Peter

    Perfect. In case anybody needs this in the future, I put together a Github repo with the code: https://github.com/judsonmitchell/wp-data-access-buttons

    Plugin Author Peter Schulz

    (@peterschulznl)

    Thank you so much Mitchell! 🙂

    I’ll add a link to the plugin website.

    Great! 🙂
    Peter

    YuppiDu

    (@andreavecchi71)

    Hi Mitchell, I’m interested in testing your plugin 😉

    If I understood correctly by reading your documentation, it seems that it works only with “WPDA publications” (not on “WPDA data-projects”), am I right?

    BTW, the goal that I want to reach is to show a table, having records ordered in a certain way (not the insertion order) and would like to add a simple “add new record” button on-top of the table.

    I think that I could simply use a “WPDA publication” (pointing to a pre-ordered database view) and add the a.m. button on-top of it, by using your plugin.

    I’m forced to implement this “trick” because I cannot – in this moment – set a custom ordering in a “WPDA data-project” table.

    I would really appreciate a small tutorial to reach the goal that I described, which could be interesting also for other developers.

    TKS in advance!

    YuppiDu

    (@andreavecchi71)

    WARNING: I installed the plugin for testing purpose, I didn’t touch any of my publications (I didn’t add any JSON to any “advanced table options”) and… all of them was not visible anymore on my website…

    Maybe there’s a kind of incompatibility with the latest version(s) of the WPDA plugin…

    The plugin is only designed to work for Data Publisher. As far as I know, Data Projects does not afford you the opportunity to add custom JS to its views.

    The plugin is still working for me using v3.1.5 of WPDA (Publisher). I would suggest open up Developer Tools and sharing with us whatever errors you see in the console.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.