Excel Export with complete datas

Excel Export with complete datas

dg_datatablesdg_datatables Posts: 53Questions: 10Answers: 1
edited March 2018 in Buttons

I'm using a table with over 30 columns. Some of the columns contains huge datas. For readable reason - and not making the table to wide - i'm cutting the datas in some columns like this:

{ "render": function (data, type, row) {
     if (data.length > 25)
      {
              var anzklass = '<span title="'+data+'">';
              anzklass += data.substring(0, 23) + '...';
              anzklass += '</span>';
              return anzklass;
      }
     return data;
      }, "targets": 30 }

This works fine. All big datas will be cutted and the complete content will be seen in a mouse-over.

But:
I also need a Excel Export. I manage this with the normal "Buttons:[Excel]" function. This also works fine, but in the Excel-file i only see the cutted datas, not the complete data.

How can i solve this, that i can see in the screen the "cutted" datas and in the Excel-file the complete datas?

Thanks a lot in advice.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,376Questions: 26Answers: 4,957

    You will want to make the modification for only the display option. This render example will chow you how:
    https://datatables.net/manual/data/orthogonal-data#Computed-values

    Kevin

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

    Hi,

    My comment on this thread will be useful, that has an example of those different options for render. Likewise, this page on columns.render.

    Cheers,

    Colin

  • dg_datatablesdg_datatables Posts: 53Questions: 10Answers: 1

    I added the type request in line 2, like:

    if (data.length > 25 && type === 'display')

    But this doen't work. The datas will shortend in the Display AND in the Excel-file.

  • dg_datatablesdg_datatables Posts: 53Questions: 10Answers: 1
    edited March 2018

    I changed the code like Colin's advice:

     { "render": {
             "display": function (data, type, row, meta) {
                       if (data.length > 25)
                       {
                             var anzklass = '<span title="'+data+'">';
                             anzklass += data.substring(0, 23) + '...';
                             anzklass += '</span>';
                             return anzklass;
                        }
                        return data;
                     },
               "filter": function (data, type, row, meta) {
                        return data;
                      }
           }, "targets": 30 }
    

    Sorry, but no change. Still cutted on display and Excel.

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

    I'm poking around here too! Hope to get back shortly :)

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

    Got there - this example does it. It's creating an additional type, 'export', which is then picked up in the render function.

    Hope this works for you,

    C

  • dg_datatablesdg_datatables Posts: 53Questions: 10Answers: 1

    It works! Great!

    Thanks a lot.

This discussion has been closed.