I am try to add export buttons to my datatable, my table include select boxes inside, the problem is - it export all the options values included in the select box... A am us
Credit to Mikhail Ushakov for getting me started. There were some opportunities to simplify the code and to make it work a little smoother (in my case) the biggest problem being that just about everything in my tables is a link or select. In the case of links, the other code was also capturing the html for the link, not the text. In my case I also had weird stuff like tables, so I had to anticipate multiple children in each node. Also opted not to use JQuery ;)
exportOptions: {
format : {
body : (data, row, col, node) => {
let node_text = '';
const spacer = node.childNodes.length > 1 ? ' ' : '';
node.childNodes.forEach(child_node => {
const temp_text = child_node.nodeName == "SELECT" ? child_node.selectedOptions[0].textContent : child_node.textContent;
node_text += temp_text ? `${temp_text}${spacer}` : '';
});
return node_text;
}
}
},