The data in the row that is clicked when clicking on the table row is not working
The data in the row that is clicked when clicking on the table row is not working
ertugrul
Posts: 6Questions: 3Answers: 0
// I created a table with json
$.ajax({
type: "POST",
url: "yardim_takip_komsorgu.php",
dataType: "html",
// async: false,
data: {Tc_No: ara, durum: "diger"},
success: function (donenveri) {
var dt_yrdm = JSON.parse(donenveri);
tbl2_y = $('#kom_yrdmkarar, #kom_yrdmkarar_m').DataTable();
tbl2_y.destroy();//sonraki gelen verilerde hata almamak için önce tablo siliniyor sonra tekrar oluştrlyr
$('#kom_yrdmkarar, #kom_yrdmkarar_m').DataTable({
// "lengthMenu": false,
"searching": false,
// "autoWidth":false,
"select":true,
data: dt_yrdm,
columns: [{ data: 'yardim' }, { data: 'miktar' }],
"columnDefs": [{ "targets": 0 ,"width": "90%"}, { "width": "10%", "targets": 1 }
],
});
}
});
//I'm trying to transfer data to another table when I click on the following code
// But it does not work
var scln_tbl = document.getElementById("secilenler");
var te_ = $("#kom_yrdmkarar_m").DataTable();
te_.draw();
var idno = 1;
$('#kom_yrdmkarar_m tbody').on('click', 'tr', function () {
var d_y = te_.row(this).data();
alert("asd" + d_y[0]);
var rw = scln_tbl.insertRow();
var cell1 = rw.insertCell();
var cell2 = rw.insertCell();
cell1.innerHTML = d_y[0];
cell2.innerHTML = "<input id='" + idno + "' type='number' style='width:40px' value=''>"
idno = idno + 1;
//alert('You clicked on ' + data[0] + '\'s row');
var secil = $("#secilenler").DataTable();
});
This discussion has been closed.
Answers
please help me
Are you sure you want to do it that why where a single click moves the data?
In this example, user selects row(s) and clicks move.
http://jsbin.com/hayowuk/edit?html,js,output
having said that, here is an example that moves the row on a single click
http://jsbin.com/duxereg/edit?html,js,output