1

I have a DataTable that includes yadcf filters in the header. Therefore, when I use the export to PDF and Excel buttons, I would like the column titles of those reports to come from the footer of the DataTable. How would I accomplish that?

My current buttons code gets the header of the DataTable without the yadcf filter options. However, I would like to remove the header completely so that I can use the default text in the yadcf filters as the column titles.

  buttons: [
              {
                extend : 'excel',
                exportOptions : {
                  format : {
                    header : function (mDataProp, columnIdx) {
                      var htmlText = '<span>' + mDataProp + '</span>';
                      var jHtmlObject = jQuery(htmlText);
                      jHtmlObject.find('div').remove();
                      var newHtml = jHtmlObject.text();
                      return newHtml;
                    }
                  }
                }
              },
              {
                  extend: 'pdfHtml5',
                  orientation: 'landscape',
                  exportOptions: {
                    format : {
                      header : function (mDataProp, columnIdx) {
                        var htmlText = '<span>' + mDataProp + '</span>';
                        var jHtmlObject = jQuery(htmlText);
                        jHtmlObject.find('div').remove();
                        var newHtml = jHtmlObject.text();
                        return newHtml;
                      }
                    }

                  }
              },
          ],
Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
OverflowingTheGlass
  • 2,324
  • 1
  • 27
  • 75
  • not sure about the "taking from footer" but you can do some google about yadcf and exporting or take a look at these two links https://github.com/vedmack/yadcf/issues/284 and https://stackoverflow.com/questions/37940653/incorrect-header-when-exporting-to-pdf-with-yadcf-filter – Daniel Dec 05 '17 at 07:41
  • First of all, thank you for an excellent product - it has made my life much easier. Secondly, I am currently using the solution from the GitHub issue. However, I would like to use the default labels of the yadcf filters as my header to avoid clutter, which is why I was looking to pull from the footer. Or possibly just manually set the export column titles. – OverflowingTheGlass Dec 05 '17 at 11:11
  • ok, you might want ask it on the datatable forum then – Daniel Dec 05 '17 at 11:59
  • I'll do that. I tagged datatables on here, so I figured that might Garner some attention – OverflowingTheGlass Dec 05 '17 at 12:03

0 Answers0