Modification of request data

Modification of request data

Gabriel925Gabriel925 Posts: 2Questions: 1Answers: 0

I have been reading this forum for some time and I have not yet been able to find an answer to the problem I have.

When exporting servers side processing table, I try to change the requestData.length parameter within the requests data, I successfully caught the data I need with the help of prexhr, but ajax arrives with old, unchanged data requestData.length = 10.

var exportfunction = function (e, dt, button, config) {
                var self = this;
                var oldStart = dt.settings()[0]._iDisplayStart;
                debugger;
                dt.one('preXhr', function (e, s, data) {
                    debugger
                    var dataObj = JSON.parse(data);
                    dataObj.requestData.length = 20;
                    data = JSON.stringify(dataObj);
                    debugger;

                            dt.one('preDraw', function (e, settings) {
                               
                                oldExportAction(self, e, dt, button, config);

                                dt.one('preXhr', function (e, s, data) {
                                    
                                    settings._iDisplayStart = oldStart;
                                    data.start = oldStart;
                                });
                                setTimeout(dt.ajax.reload, 0);

                                return false;
                            });


                });
                dt.ajax.reload();

Please help me

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You've got some odd next one() going on there.

    If you're trying to export all data when serverSide is enabled, these two threads, here and here, may be useful.

    Colin

  • Gabriel925Gabriel925 Posts: 2Questions: 1Answers: 0

    Thanks for the reply, I have already read both threads and unfortunately have not found a solution.

    It is not entirely clear to me how it is possible to get an unchanged data in an ajax
    request data that triggers after the preXhr event in which I changed the data?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    As Allan said in one of the threads I linked :

    Basically, your best option is to create the file on the server-side.

    It currently isn't supported on the client (or the server), so it would be more efficient for your code to be written server-side where the data is located.

    Colin

Sign In or Register to comment.