The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Using DataTables with Formidable Pro
Don't be scurred! It's easy!
- Go to http://www.datatables.net/download/ and download the zip file.
- Push the zip file to /wp-content on your web server and unzip the file.
- You have a choice. You can put your JavaScript tags in the "Before Content" of your view, in which case DataTables will be configured to work only on the one view
<script type="text/javascript" charset="utf-8" src="http://yourUrl.com/wp-content/DataTables-1.9.4/media/js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="http://yourUrl.com/wp-content/DataTables-1.9.4/media/js/jquery.dataTables.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#your_data_table_id').dataTable(); } ); </script>
or you can put the tags in your theme functions.php, in which case DataTables will be available to all of your views.
function set_dataTables_Configuration() { ?> <script type="text/javascript" charset="utf-8" src="http://yourUrl.com/wp-content/DataTables-1.9.4/media/js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="http://yourUrl.com/wp-content/DataTables-1.9.4/media/js/jquery.dataTables.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#your_data_table_id').dataTable(); } ); </script> <?php }
I started by getting DataTables to work in one view and, later, I moved the scripts to functions.php.
- Import the DataTables demo CSS stylesheet to get started. Either put the following in your theme style.css or wrap it in <style> tags and put it in "Before Content" of your view:
@import "http://yourUrl.com/wp-content/DataTables-1.9.4/media/css/demo_table.css";
- Assign the id and DataTable's default CSS class ("display") to your view's table tag e.g.
<table id="your_data_table_id" class="display">
- And, voila, your done! Now, go to http://www.datatables.net/blog/Getting_started_with_DataTables%3A_First_steps if you have any questions.
January 15, 2014 at 11:32 pm
Whoops! Don't forget to invoke the set_datatables_Configuration function, if you decide to put the JavaScript in functions.php e.g.
February 10, 2014 at 9:15 am
Can you help me get these working?
http://datatables.net/extras/tabletools/
http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html
February 10, 2014 at 1:52 pm
The problem I had with Table Tools is that it would not display. So I went to the Data Tables support forum and got resolution. Try using the support forums; they're very helpful over there. Here's the thread I started, which helped me to resolve my problem:
http://datatables.net/forums/discussion/19114/tabletools-buttons-do-not-display
February 10, 2014 at 1:55 pm
As far as column sorting look up the documentation on aoColumnDefs and in particular the bSortable option. Here's what I have:
"aoColumnDefs":
[
{ "bSortable": false, "aTargets": [ 2 ] }
],
Which means that all the columns should be sorted except column #3 (the columns start at zero e.g. 0, 1, 2, ...).
May 26, 2014 at 9:28 am
Note that
#your_data_table_id
needs to be unique for each table you display.
In the setup code that you put into your theme or in functions.php, you need to define each table with its own unique table ID:
In your FP view, in the "before content" area, you need to be sure to use the unique DataTable ID that you defined in the code you put into your theme or functions.php.
May 26, 2014 at 9:29 am
Here are some additional examples and documentation of using DataTables with FP:
Example: DataTables – display a table of a form’s entries
http://community.formidableforms.com/help-desk/example-datatables-display-a-table-of-a-forms-entries/
Scrollable, Seachable, Sortable table of entries via direct SQL query
https://formidableforms.com/help-desk/scrollable-seachable-sortable-table-of-entries-via-direct-sql-query/
Filtered – Scrollable, Seachable, Sortable table of entries via direct SQL query
https://formidableforms.com/help-desk/filtered-scrollable-seachable-sortable-table-of-entries-via-direct-sql-query/
Discussion closed.