• Resolved jimblug

    (@jimblug)


    Hey, i try to use a fucntion that i find on the website you provide here :
    https://www.datatables.net/

    My function work good but when i refresh the page i have a error message in alert that say :

    DataTables warning: table id=tablepress-2 – Cannot reinitialise DataTable. For more information about this error, please see https://datatables.net/tn/3

    The code i create work, but block every plugin you provide.
    I want to know if i can include this code into the Custom Commands: window you provide on your plugin ?

    here the code i use:

    jQuery(document).ready(function($){
    var table = $('#tablepress-2').DataTable( {
    paging: false,
    searching: false,
    columnDefs: [
            { targets: [0,1,2,3], visible: true},
            { targets: '_all', visible: false }
        ]
    } );
      
    $('.toggle-vis').on( 'click', function (e) {
     
            // Get the column API object
            var column = table.column( $(this).attr('data-column') );
     // Toggle the visibility
            column.visible( ! column.visible() );
        } );
    } );
    
    • This topic was modified 3 years, 11 months ago by jimblug.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, it’s not directly possible to use this inside a “Custom Command”, as there’s also JS code that comes outside of the DataTables call.
    It would be possible to integrate this with a plugin filter hook, which would require some small PHP code. However, I would instead suggest to then simply handle the full DataTables integration with this code, i.e. to uncheck the “Use DataTables” checkbox on the table’s “Edit” screen.

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Commands Issue’ is closed to new replies.