html5csv icon indicating copy to clipboard operation
html5csv copied to clipboard

export selected in dropdown

Open asakapab0i opened this issue 10 years ago • 3 comments

Hi, can you add it to csv when the element is a dropdown and only select the selected option in the dropdown?

Is it possible?

Thanks!

asakapab0i avatar Dec 22 '14 04:12 asakapab0i

Do you have user input and select elements inside a table, and you want to capture the inputs from the user?

This could be accomplished by modifying the fromTable function at about line 298 of https://github.com/DrPaulBrewer/html5csv/blob/master/html5csv.js

At this point the table cell is being processed. Now it obtains the text of table cell with item=$(this).text(). But it is possible to use $(this).find('select') or $(this).find('input') at this point to detect any select or input elements inside the cell. Any additional code needs to be separated into if-else blocks depending on whether the table cell contains text, an input element, or a select box.

This doesn't seem too difficult. If you want to write it and send me a pull request, I think a solution would get the "val" of <input ...> elements and the selected element from a <select>

If you don't know jQuery, I may eventually write it. It sounds like a useful feature.

DrPaulBrewer avatar Dec 22 '14 06:12 DrPaulBrewer

I've managed to implement this on datatables nevertheless I'll add it here

Thanks!

asakapab0i avatar Dec 22 '14 16:12 asakapab0i

Sounds good.

DrPaulBrewer avatar Dec 23 '14 08:12 DrPaulBrewer