Add data parameters before draw

Add data parameters before draw

bstras21bstras21 Posts: 7Questions: 2Answers: 0

Does anyone know how to dynamically add a parameter to the ajax call before table.draw() so my request has new parameters?

Answers

  • bstras21bstras21 Posts: 7Questions: 2Answers: 0
    edited March 2015

    I need to pass my parameters to data but I do not know how to do that.

  • bstras21bstras21 Posts: 7Questions: 2Answers: 0

    I am using DataTables 1.10

    Does anyone know how to dynamically add a parameter to the ajax call before table.draw() so my request has new parameters? I've looked everywhere and cannot find an answer.

    I have buttons that a person can press and based on that button send different parameters to the server.

    $('#mytable').DataTable({
            iDisplayLength: 10,
            responsive: true,
            processing: true,
            serverSide: true,
            searching: false,
            bLengthChange: false,
            bProcessing: true,
            paging: true,
             ajax: {
                url: me.url,
                dataType: 'json',
                cache:false,
                type: 'GET',
                data: function ( d ) {
                    $.extend( d, me.data);
                    d.supersearch = $('.my-filter').val();
                }
            },
            columns: me.columns,
            columnDefs: me.renderer,
            initComplete: function() {
    
            }
        });
    

    This all works fine but then I try to tie it to a button to pass new parameters.

    $('.button').on('click', function(){
          var table  = $('#mytable').DataTable();
          table.ajax.params({name: 'test'}); <- I want to do something like this
          table.draw(); 
    })
    
  • bstras21bstras21 Posts: 7Questions: 2Answers: 0

    Really, no answer????????

This discussion has been closed.