export hidden column

export hidden column

idris_bengaliidris_bengali Posts: 20Questions: 3Answers: 1

have a report with 10 columns. one of the columns is Notes. This field is 500 char. To prevent the Notes column from wrapping the contents and causing a single report line to occupy multiple rows, the plan is to output only the first 50 characters of the notes field. Have another hidden Notes field which will have the entire 500 char.

When user chooses to export to excel/csv the Hidden Notes field needs to be exported instead of the displayed Notes column. Please suggest a way to achieve this. Thank you.

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @idris_bengali ,

    You don't really need the hidden field - just use orthogonal data with columns.render. You could truncate the notes field on the display, as in this example here, and then just export the full data (something like this, where it's rendered differently on the export),

    Hope that helps,

    Cheers,

    Colin

  • idris_bengaliidris_bengali Posts: 20Questions: 3Answers: 1

    Thank you Colin... I will adopt this approach

  • idris_bengaliidris_bengali Posts: 20Questions: 3Answers: 1

    after some more searching I found this simple render method and after carefully mimicking the syntax, not able to get the desired results.

        "columnDefs": [
            // Turn off Ordering for columns which hold the hyperlinks
            { "orderable": false, "targets": [ 3, 12 ]  } ,
            // Notes column, show first 50 characters
            {
              "targets": 11,
              "render": function(data, type, row) {
              if ( type === 'display') {
                return data.length > 50 ?
                   data.substr( 0, 50 ) + '...' :
                   data;
              }
              return data;
              }
            }
        ],
    

    the display works fine shows the first 50 and ... when length > 50, but the export is not sending the entire field. It is exporting what is displayed.

    thank you once again colin for setting me on the right path.

  • idris_bengaliidris_bengali Posts: 20Questions: 3Answers: 1

    just to mention the data source is not ajax/json. the rendering is done with html merge.

  • idris_bengaliidris_bengali Posts: 20Questions: 3Answers: 1

    Resolved

    1) defined the "columns": [ ]
    2) in the buttons sections set exportOptions >> orthogonal: 'export'

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    That's it - see those two examples from my earlier post. Glad all working,

    C

This discussion has been closed.