Adding search string too in print of datatables

Adding search string too in print of datatables

thegreatthegreat Posts: 1Questions: 1Answers: 0

Hello. I have been using datatables widely and I am beginner with 2 months of experience with datatables. We are using search field in every column for flexible search options.

Now I want the the data entered in the search fields too to be on the print so one could know them when they refer it after at later days. The traditional print captures the search but its not a solution as it wont print paginated data.

Expected Print:

Actual Print:

I tired to get the values of the input field and pass it to the messageTop parameter of print.

var tableTitle = $('#enqViewTable > thead > tr:nth-child(2) > th:nth-child(15) > div > input[type="text"]').val();

            var table = $('#enqViewTable').DataTable({
                dom: 'Bfrtip',
                buttons: [
                    {
                        extend: 'print',
                        messageTop: tableTitle
                    }
                ],
                colReorder: true,
                responsive: true

            });

But since the datatables is initialized at the beginning, only empty string is getting passed. I can initialize on click of print button. But is there any other correct or simple way to achieve this ?

This discussion has been closed.