Wordpress gravityforms_datatables plugin Export Buttons

Wordpress gravityforms_datatables plugin Export Buttons

alviasalvias Posts: 11Questions: 2Answers: 1
edited May 2017 in Free community support

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

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    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

  • alviasalvias Posts: 11Questions: 2Answers: 1

    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"

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    There is a comma missing immediately before the pageLength option in your code. That is causing the syntax error.

    Allan

  • alviasalvias Posts: 11Questions: 2Answers: 1

    Thank you very much.

    Is there a way to donate, to support you and your work?

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Check the "Support" and "Purchase" options on the left. I know your help will be appreciated.

  • alviasalvias Posts: 11Questions: 2Answers: 1

    Ok, I will.

    Just one more thing, how do i enable Multiple tables with the code above?

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    You should just need to change your jQuery selector to pick up all of the tables you want as shown in this example.

    Allan

  • alviasalvias Posts: 11Questions: 2Answers: 1

    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.

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    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

  • alviasalvias Posts: 11Questions: 2Answers: 1

    Ok, I will.
    I purchased your Datatables now.
    Keep up the good work, Thank you

This discussion has been closed.