diego.martinez diego.martinez -4 years ago 161
Javascript Question

datatables dropdown combobox

Im using Datatables from https://datatables.net.
One of the columns on the datatable has a dropdown combobox as cell data.
When I push a button, I need to get the selected value of the combobox inside the selected row.

$.each($("#prize_selector tr.selected"), function () {
var row = prizes_table.row(this).data();

but no success. How can I access the DOM select inside the cell, without traversing all the input selects on the table? (there are a lot).

edit the console throws row[3].$ is not a function

Answer Source

I assume you're using Select extension to select rows.

Below is a correct way to access select element for each selected row:

table.rows({ selected: true }).every(function(){
   var $select = table.$('select', this.node());
   var $option = table.$('select option:selected', this.node());

   console.log($select.val(), $option);

See this example for code and demonstration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download