Apply downloader buttons with nested table

Apply downloader buttons with nested table

estebanoasisestebanoasis Posts: 4Questions: 0Answers: 0

Hi dears,
I've got a table with two buttons(excel and pdf). When i initialize the main table there is not problem, but when i get the nested table trough ajax i try to initialize it again but it doesnt work, i understand DataTables dont recognize nested tables, so i tried to initialize the nested table as a new DataTable wich give me only buttons for it. Whatever, i need to be able to download the entire table.
I hope you can help me. Thanks

Replies

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    Possibly you can create custom buttons for the nested table, see this example, that click the main table buttons using button().trigger().

    Kevin

  • estebanoasisestebanoasis Posts: 4Questions: 0Answers: 0

    Thanks Kevin for your reply, but the problem isn't the action button, the problem is the main button doesnt download all the data table including the nested table, only the main one. I dont know if i am explaining correctly

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    I didn't understand your first post so my answer doesn't apply. Can you post a link to your page or a test case showing how you are creating the nested table? Is there a nested table for each row? Are you fetching, via ajax, each nested table separately? We need to understand your current solution to provide specific help.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    One option is to place the nested table data in hidden columns using columns.visible. These can be exported along with the rest of the table data.

    Another option is to write some custom code to export data that doesn't exist within the main table. This thread shows a way to export Child detail rows. The code you write for the customize function will be different depending on your solution.

    Kevin

  • estebanoasisestebanoasis Posts: 4Questions: 0Answers: 0

    Here is my test case
    https://live.datatables.net/torohoci/1/edit?html,css,js,output

    You can see i m trying to insert a new row with a nested table by clicking on each "<tr>"

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    Did you look at the Child Row Details example I linked to? It looks like its doing the same thing as your test case but uses Datatables API's to build the child/nested table. The format function can be used to generate a table instead of the description list in the example. My suggestion is to start with this for the nested table.

    Your test case generates a Javascript error when clicking the tr. This is due to using destroy() then inserting a new row into the HTML table that does not have the same number of columns the rest of the table has. It is only inserting one td instead of three in the table. So Datatables is not able to process the table when reinitialized.

    Kevin

  • estebanoasisestebanoasis Posts: 4Questions: 0Answers: 0

    Hi Kevin,

    Thanks for your help, i ve made what you said but the buttons are still not working. They just download the main table without new data

  • kthorngrenkthorngren Posts: 21,324Questions: 26Answers: 4,949

    i ve made what you said but the buttons are still not working.

    What exactly did you do? Can you show us in a test case?

    The child detail rows aren't exported. As I mentioned above there are a couple choices. First is to place the child row data in hidden columns using columns.visible. The other is to use the customize function to export the child rows. An example can be found in this thread. Did you try either of these?

    Kevin

Sign In or Register to comment.