Condition based data export from datatable to excel

Condition based data export from datatable to excel

prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Replies

  • prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0

    please help

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Please explain your requirements in sufficient detail.

  • prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0

  • prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0

    based on deliquent value 'D', i want to export excel with current-delinquent values with only 'D'

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    That is done with the rows option of buttons.exportData(). The easiest method would be to provide a function for the rows selector (see row-selector) which will only select rows with a D.

    Allan

  • prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0
    edited October 2020

    I need below logic inside export options then only i can able to export excel of columns having values with D but after placed in export options its showing warning..

    var indexes = table.rows().eq(0).filter(function (rowIdx) {
    return table.cell(rowIdx, 7).data() === 'D' ? D : C;
    });

    please help me!!!!
    thanks
    hari

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    Allan means something more like this:

          {
            extend: 'excel',
            exportOptions: {
              rows: function ( idx, data, node ) {
                return data[1] === 'Software Engineer' ?
                  true : false;
              }
            }
          },
    

    See this example:
    http://live.datatables.net/witizici/1/edit

    Kevin

  • prasadhari009prasadhari009 Posts: 28Questions: 7Answers: 0
    edited October 2020
    {
      extend: 'excel',
      exportOptions: {
        rows: function ( idx, data, node ) {
          return data[7] === 'D' ? true : false;
        }
      }
    },
    

    this is working fine

    thanks kevin

    hari

This discussion has been closed.