how to get selected row from form button?

how to get selected row from form button?

kytankytan Posts: 6Questions: 3Answers: 0

How do i get selected rows from the grid on my form button?
when i selected a few rows on the grid and click on a button like "Lookup", i am able to do an ajax post call to my php code but where do i get the selected row data on my php code?

this is my ajax call
$.ajax({
type: 'POST',
'headers': {'X-CSRF-TOKEN': 'uTKwGdKrCYoOAL06imtREZ7WJUk839kRUwKcSxFa'},
data: $(this).serialize(),
error: function (jqXHR, textStatus, errorThrown) {
alert("error" + jqXHR + " : " + textStatus + " : " + errorThrown);
},
url: '/lookup/2'
})

$data = Input::all();
when i do a var_dump( $data );
i get empty.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    it simple if you have the selection plugin. You can see it work here: http://live.datatables.net/zamoqohu/1/edit

    $(document).ready( function () {
      
      // datatable
      var table = $('#example').DataTable( {
            select: {
                style: 'multi'
            }
        });
      
    // button event handler for getting the data for selected rows.
      $("#btnGetData").click(function() {
        
         var selData =   table.rows(".selected").data();
        alert(selData.length);
      });
      
    } );
    
    
  • allanallan Posts: 63,889Questions: 1Answers: 10,530 Site admin
    Answer ✓

    Event better is to use the selected option of the selector-modifier option:

    table.rows( { selected: true } ).data();
    

    That removes any dependence on the DOM.

    See also the manual for this information.

    Allan

This discussion has been closed.