DataTables-Hide-Empty-Columns icon indicating copy to clipboard operation
DataTables-Hide-Empty-Columns copied to clipboard

Does perPage work with AJAX data?

Open mikeee324 opened this issue 8 years ago • 4 comments

Just found this and I've been trying to make this work with my table that get its data using AJAX.
It appears to hide the columns when they're empty but the columns don't come back if I navigate back to a page where they're not empty.
For the columns to show again I have to refresh the page.

I've copied the bit from the example for perPage the only difference seems to be that I'm loading the data with AJAX instead of it already being on the page.

Is there something I could have missed?

Here's how I've created the table if it's any help:


    $(document).ready(function () {
        var oTable = $('#e-table').dataTable({
            columns: [
                {title: "Name"},
                {title: "Serial Number"},
                // Some more columns generated by PHP
            ],
            serverSide: true,
            "bInfo": false,
            "bLengthChange": false,
            "pageLength": 15,
            "oLanguage": {
            "sZeroRecords": "Nothing to display",
                    "sSearch": ""
            },
            hideEmptyCols: {
                columns: <?php echo $columnsToHide; ?>,
                perPage: true
            },
            "ajax": '/ajax_table/'
        });
    });

The data returned from /ajax_table/ is just as the dataTables spec says it should be.

mikeee324 avatar Apr 11 '16 16:04 mikeee324

Hey Mike,

Thanks for using the plugin and opening the ticket, and I apologize for the response delay. I had to take a break from personal projects like this, due to the demands in my professional career.

I will work on this and see whats causing the issue, then update you asap!

jhyland87 avatar Aug 08 '16 16:08 jhyland87

No probs! If there's anything else you need from me, let me know.
There's no big rush for it, it's a 'nice to have' :)

mikeee324 avatar Aug 08 '16 17:08 mikeee324

Nobody handled that so far?

AlexeyKosov avatar May 08 '18 20:05 AlexeyKosov

@mikeee324 I just merged the pull request from @AlexeyKosov, and committed an example of a datatable using an ajax source and this plugin. Let me know if you have any other questions/issues

jhyland87 avatar May 30 '18 17:05 jhyland87