Wordpress gravityforms_datatables plugin Export Buttons
Wordpress gravityforms_datatables plugin Export Buttons
Hello
I am working on a Wordpress project right now, for what i bought the Gravity-Forms jQuery Datatable Plugin.
Unfortunately it does not contain the Export Buttons.
https://datatables.net/extensions/buttons/examples/html5/simple.html
I asked the author if he can add them but he does not know if he can do it in time.
The project only runs local so i cannot link it here.
If i try to add the Export Buttons I only get a blank table.
I hope someone can help me with the little information i can give.
The part that initialises the tables is the following:
/**
* init the datatable
*/
function spgfdt_wp_footer()
{
if( $_SESSION[ 'dt_params' ][ 'form_id' ] )
{
$form = GFAPI::get_form( $_SESSION[ 'dt_params' ][ 'form_id' ] );
if( wp_script_is( 'datatable' ) )
{
$locale = get_locale();
?>
<script type="text/javascript" class="init">
jQuery(document).ready(function() {
jQuery('#gravitylist_<?php echo $_SESSION[ 'dt_params' ][ 'form_id' ]; ?>').DataTable( {
"processing": true,
"serverSide": true,
"scrollX": true,
<?php
/**
* init paging
*/
if( !rgar( $form, 'spgfdt_paging' ) )
{
echo '"paging": false,';
} else
{
echo '"pageLength": ' . $form[ 'spgfdt_paging' ] . ',';
echo '"lengthMenu": [ 10, 25, 50, 100, 500 ],';
}
/**
* init ordering
*/
if( !rgar( $form, 'spgfdt_ordering' ) )
echo '"ordering": false,';
/**
* init searching
*/
if( !rgar( $form, 'spgfdt_searching' ) )
echo '"searching": false,';
/**
* set language
*/
if( is_file( plugin_dir_path( __FILE__ ) . 'Datatables/languages/datatables.' . $locale . '.json' ) )
{
?>
"language": {
"url": "<?php echo plugins_url( 'Datatables/languages/datatables.' . $locale . '.json', __FILE__ ); ?>"
},
<?php
}
?>
"ajax": "<?php echo admin_url( 'admin-ajax.php' ); ?>?action=get_gravitylist"
} );
} );
</script>
<?php
}
}
}
Answers
Can you show me your rendered Javascript (i.e. "View source" on the page) and also check to see if there are any messages or errors in your browser's console please.
Allan
Thank you for the response
view source is made by google chrome and attached to this comment
The console gives me this responce:
jquery-migrate.min.js?ver=1.4.1:2 JQMIGRATE: Migrate is installed, version 1.4.1
(index):280 Uncaught SyntaxError: Unexpected string
line 280 is:
"pageLength": 25,"lengthMenu": [ 10, 25, 50, 100, 500 ], "ajax": "http://192.168.0.246/wordpress/wp-admin/admin-ajax.php?action=get_gravitylist"
There is a comma missing immediately before the
pageLength
option in your code. That is causing the syntax error.Allan
Thank you very much.
Is there a way to donate, to support you and your work?
Check the "Support" and "Purchase" options on the left. I know your help will be appreciated.
Ok, I will.
Just one more thing, how do i enable Multiple tables with the code above?
You should just need to change your jQuery selector to pick up all of the tables you want as shown in this example.
Allan
The plugin i am using has its selector written in PHP, should i just exchange it?
I have attached a test table, how does the code have to look like if i want 2 tables listing the different classes? In this case A and B.
I suspect you'd need to ask the plug-in author. If you don't already have the second table on the page you'd need to create that second table first.
Allan
Ok, I will.
I purchased your Datatables now.
Keep up the good work, Thank you