PDF export - row output depending on column content

PDF export - row output depending on column content

bitmacherbitmacher Posts: 15Questions: 6Answers: 0

Hello togheter,

I have a topic again where I get stuck. Table with this content:

Columns:
Name | Surname | Job | Active
Maier | Markus | Tester | Yes
Muller | Nadine | Tester | No
Meier | Joe | Tester | Yes

If I do now an export, I only want to export the rows that has a Yes in the "Active" column. If I set the filter by hand beforehand, it's no problem. But I would like it to be automatic with a special Button.

I have found a lot of stuff in the forum with exportOptions: { orthogonal: "pdf-active" } and some render: function (data, type, row) { function. But nothing what describes my topic, I need a little hint.

Do I have to integrate it in the columns....?

{ data: "contact.active",
                render: function (data, type, row) {
                  if (row.contact.active == 1) {
                    return 'Yes';
                  } else {
                    return 'No';
                  }
                  return data;
                }
              },

Or is it necessary in the exportOptions with an IF....?

exportOptions: {
                        orthogonal: "pdfactive",
                        modifier: {
                                order: 'current',
                                page: 'all',
                                selected: null
                        },

if ( type === 'pdfactive' ) {
                      if(data!='')
                      {
                         return ........;
                      }
                      else
                      {
                         return "";
                      }
                      return data;
                    }
.....

Thanks a lot for a short hint.....

Best regards
Mac

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    You're close. You would use row-selector in buttons.exportData() - that can be a function so you can test for your "Yes" value there. This example here demonstrates that nicely.

    Colin

  • bitmacherbitmacher Posts: 15Questions: 6Answers: 0

    Hello Colin,

    Thanks for the fast respond. I couldn't answer much faster because of work.

    I've tried it and the example from you works perfect. But unfortunately not with my datatable. I reduced the file to the minimum, but it still doesn't work. I get an empty pdf file only with headers.

    I tried also some different if's:

    if (data[13] == "1") {
    if (data[13] == 1) {
    if (data[13] == "Yes") {
    if (row.contact.active == "1"
    if (data.contact.active == 1

    and so on....and also with different columns. But it is still not working.

    I will continue to try out what could be the cause and then write a feedback.

    Best regards
    Markus

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Could you update my example with your data/config so we can take a look, please,

    Colin

This discussion has been closed.