Server side processing: export all rows

Server side processing: export all rows

bliksempiebliksempie Posts: 17Questions: 4Answers: 0

Please can you advise how I would export all content when using server side processing to CSV? Using the examples work only for local data, not ajax processing. Here is what I am using:

buttons: [{
    extend: "collection",
    className: "exportButton",
    text: "Export",
    buttons: [{
        extend: "csv",
        text: "Export as CSV",
        exportOptions: {
            modifier: {
                page: "all",
                search: "none"
            }
        }
    }]
}]

Is there something specific I must do to make it work with server side processing? I can't find anything in the docs, but it may be because I am not sure how to search for this particular case.

Thanks!

This question has accepted answers - jump to:

Answers

  • bliksempiebliksempie Posts: 17Questions: 4Answers: 0

    To elaborate: the above example, using local data, exports all data, but with server side processing, it exports only the current page.

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

    The Datatables export buttons support exporting data at the client. With Server Side Processing enabled the only data at the client is the current page. See this FAQ for more details.

    Kevin

  • bliksempiebliksempie Posts: 17Questions: 4Answers: 0

    Hi Kevin,

    Thanks - that is a pity - but hoping there may be a work-around.

    My data table is only showing data from one database table, but when I export the data, I want to join two database tables together, matching all the filters chosen, including all the extended columns, but ignoring pagination, and then export to file (CSV). I can do the server side processing to handle this, but not sure how to link this to the export button then. Is this possible?

    I was thinking:

    action: function ( e, dt, node, config ) {
        //some callback function here, called via Ajax?
    }
    

    Since it looks like I can do alerts here, I should be able to do an Ajax call in here, right?

  • bliksempiebliksempie Posts: 17Questions: 4Answers: 0

    Sorry - some clarification on my request: Trying it now, but not sure how to pass the selected filters, POST data or whatever is needed to filter results, through to the action.

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    Answer ✓

    You can use search() to get the search value of the global search input and, if doing column searches, you can use columns().search() to get the values of the column searches. You can pass these in the jQuery ajax() request of the custom button.

    Kevin

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Just to directly answer this question:

    Since it looks like I can do alerts here, I should be able to do an Ajax call in here, right?

    Yes - it is just a Javascript function. You can do whatever you want in there.

    There is a download button plug-in which might be of some interest - it will open a URL in an iframe which, with the correct mime type from the server, will trigger a download.

    Allan

  • bliksempiebliksempie Posts: 17Questions: 4Answers: 0

    Thank you very much. I appreciate your help!

Sign In or Register to comment.