1

Is it possible to disable pagination dynamically on a footable, that has paging, so that all the table data can be printed to excel?

For example, if the table has paging, but then when they click export, it will disable paging and show all the data without paging, so that the data can be exported with excel.

This seems to get rid of paging, but only the data from the first page will remain.

$(".foo-table").footable({ paginate: false });

Current Code:

var ft = FooTable.init('.foo-table');

function populateContractorPayments(values, reload) {
        //check filters
        $.getJSON("/PaymentsApi/GetContractorPayments", { values: JSON.stringify(values) }, function (data) {
            //console.log("Got Contractor Payments");
        }).done(function (model) {

                viewModel = ko.mapping.fromJS(model);
                var jsModel = ko.toJS(viewModel);
                ko.applyBindings(viewModel);
                //Set Page Filters
                var filters = [], def = 'All Users';
                $.each(jsModel, function (i, val) {
                    $.each(val.Roles, function (i, val) {
                        if (!filters.includes(val)) {
                            filters.push(val);
                        }
                    })
                });
                setPageFilters(filters, def);
                ft;
    }

 function printToExcelClick() {
        $(".foo-table").footable({ paginate: false });
        $(".foo-table").tableExport();    
    }
Ophiucus
  • 95
  • 4
  • 17

1 Answers1

0

You can do this by setting the pageSize to something greater than your total amount of rows.

var newSize = 5000,     
FooTable.get('.foo-table').pageSize(newSize);

This way the pagination is disabled, and you can view all the rows on one page.

Hope it helps :)

Davy Baert
  • 535
  • 4
  • 5