gyrocode checkbox

gyrocode checkbox

wuwuwuwu Posts: 52Questions: 17Answers: 0

Hi, I used gyrocode checkbox server side processing on my datatables. I need to access the other fields of the checked rows aside from the ID (rowId). How can I do that? I am using below code.

// Handle form submission event
$('#frm-example').on('submit', function(e){
var form = this;

  var rows_selected = table.column(0).checkboxes.selected();

  // Iterate over all selected checkboxes
  $.each(rows_selected, function(index, rowId){
     // Create a hidden element
     $(form).append(
         $('<input>')
            .attr('type', 'hidden')
            .attr('name', 'id[]')
            .val(rowId)
     );
  });

});

Answers

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    The Gyrocode Checkboxes plugin uses the Select extension. This example shows how to get the selected rows. If you have serverSide: true then I think you will only get the selected rows on the page.

    Kevin

  • wuwuwuwu Posts: 52Questions: 17Answers: 0

    Hi Kevin, yes I was able to get the count of all the selected checkboxes using
    table.rows( { selected: true } ).count()

    But i also need the specific columns value aside from the ID when i loop on the selected checkboxes. How can I do that? Thanks

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    You can use rows().every() to loop through the rows. There are examples in the docs showing how to get the data for the row.

    Kevin

This discussion has been closed.