Export options

Export options

rawthriverrawthriver Posts: 1Questions: 1Answers: 0

Hi. I have complex structure inside TD. Is it possible to provide some option to exclude some elements from export?
F.ex:
<td data-field="name">
<span class="name">Some Name</span><span class="value hidden">hidden data</span>
</td>

will produce in Excel text: Some Namehidden data
I need to exclude from exort elements with "hidden" class.

Answers

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Yes, you can use the format option of the exportOptions. There is an example available here. You could use a regex to get the value you want for example.

    Another option is to use orthogonal data to define the export.

    Allan

  • jasfreakojasfreako Posts: 2Questions: 0Answers: 0

    Hi allan.

    I have a similar issue as described here, but could not figure out how to use the regex to exclude the "hidden" class elements from the export.

    Could you give an example of how the exportOptions would be specified?

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    If you aren't sure about the regex, you might be best using jQuery to parse that into a DOM object and then get the text from the required cell.

    Allan

  • jasfreakojasfreako Posts: 2Questions: 0Answers: 0

    Thanks Allen,

    That is exactly what i did.

    Here's the code in case someone might need a similar solution:

    exportOptions: {
                        format: {
                            body: function (data, row, column, node) {  
                                var texts = new Array();
                                $(data).filter('.toExport').each(function () {
                                    texts.push($(this).text());
                                });
                                return texts;
                            }
                        }
                    }
    
This discussion has been closed.