Buttons icon indicating copy to clipboard operation
Buttons copied to clipboard

Add multiple render types for export

Open Jamstah opened this issue 8 years ago • 4 comments

It would be really handy to be able to customize each columns output depending on the type of export. I know the orthogonal option will allow you to set a type, but I was thinking along the lines of:

  • Extend datatables to accept an type array when calling the render
  • Have the export call render with a type of ['excel', 'export', 'display']
  • Run whichever render method exists first

Then each column can be individually configured and tweaked at the right level.

I did some web searching, some people are creating hidden columns that are only included in export to be able to individually do this without having to separate the display and export types by using the orthogonal option.

Jamstah avatar Aug 07 '17 12:08 Jamstah

A good idea - thanks for this! I'm not going to commit to implementing it in the short term, but using an array of rendering names does sound good.

DataTables avatar Aug 07 '17 12:08 DataTables

The only problem is it would break api for those who have written custom rendering functions. I was about to have a go at implementation but wondered if this would be a sticking point, where they are expecting a string.

If you're happy that would change, then I can have a go. Otherwise, what could be a better design?

Jamstah avatar Aug 07 '17 12:08 Jamstah

I think the thing to do would be to accept either an array or a string. As such, it might be that the change needs to be in DataTables core, making this a more general feature rather than just one for Buttons.

There might be some concern about performance given that it would mean adding another loop and possibly redundant checks. I'm not sure what impact it would have, but it is something worth exploring.

DataTables avatar Aug 07 '17 13:08 DataTables

Yes, but what I mean is people using datatables at the moment will already have render functions that check the type. If the do a check of 'type === "display"' and the function gets passed ['export','display'], then their check will fail, and the behaviour of their code will be changed, so we would be breaking the api.

I agree that it would have to be in datatables core. I wouldn't be too concerned about the performance, its just a quick existence lookup for each round of the loop.

Jamstah avatar Aug 07 '17 13:08 Jamstah

Its an old one this - sorry I never followed up before. I can see the possible benefit, but I think the upheaval would be too great - if you need specific formatting for one orthogonal data type over another, the rendering function used should handle that.

AllanJard avatar Oct 18 '23 16:10 AllanJard