Export Data with text box in TD of data table ?

Export Data with text box in TD of data table ?

m_arslanahmad@yahoo.comm_arslanahmad@yahoo.com Posts: 1Questions: 1Answers: 0

[Urgent] I have data table with Run time editable td like

<td> <input type="text" value = "DynamicValue" > </td>
But i am exporting this i have an issue that td's with having textboxes are not showing data in excel ? if anyone have an idea or have code please share ????

Answers

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin

    I don't think there is a way around this at the moment.

    The issue is that the value of the input element is a DOM property, while the export is reading from the stored data for the table (i.e. the string <input ...>) not the DOM element. It can be forced to use the DOM, but not a DOM property.

    It might be possible to use the customize callback, but I don't think it will be easy.

    I'll have a think about the options for this.

    Allan

  • ahmadshakilahmadshakil Posts: 1Questions: 0Answers: 0
    edited December 2017

    Below worked for me

    $("#mytable").dataTable( {
    "pageLength": pageSize,
    dom: domVal,
    "buttons": [
    {extend:'excel',exportOptions: {format: {
    body: function ( data, row, column, node ) {
    //
    //check if type is input using jquery
    return $(data).is("input") ?
    $(data).val():
    data;
    }
    }
    }}
    , {extend:'pdf'}
    ]} );

  • TronikTronik Posts: 122Questions: 28Answers: 1
    edited July 2018

    Couldnt delete post, sorry, I'll start a new question thread since I saw this marked as answered

    Hi,

    ahmadshakil's solutions doesnt work for me, it ends up exporting all html in the cell.
    Is it because I both have divs wrapping the input?

    A solution is much appreciated!

    Task: Export the entered value from input type text.

  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin

    That post was made and answered here.

    Allan

This discussion has been closed.