How to export render value

How to export render value

test42test42 Posts: 21Questions: 8Answers: 0

Hi,

I've rendered a dropdown into my datatables so the user can select a value. When I go to export that with excel, it outputs the two dropdown values together. How can I make it so it outputs what the user selects?

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,994Questions: 1Answers: 10,368 Site admin

    You need to use a custom export formatting function. In that you will have access to the original node, so you can query its DOM and return the selected value.

    Allan

  • test42test42 Posts: 21Questions: 8Answers: 0

    Got it, thanks Allan!

    The only question I have left is if we're rendering the data client side, can we still use any of the API commands to pull the cell data or do we have to query each cell using jQuery to get the value? And if that's the case would we have to leverage the row and column parameters to loop through each row to pull the correct cell?

  • allanallan Posts: 62,994Questions: 1Answers: 10,368 Site admin
    Answer ✓

    The formatting function has the node passed in, so if for example you wanted to get a selected value you might use: $('option', node).is(':selected'). You could do it without jQuery as well if you prefer.

    Allan

  • test42test42 Posts: 21Questions: 8Answers: 0

    Excellent, got it working, thanks again!

This discussion has been closed.