I\'m using DataTable.js to showing the data and I have some
This works for me hopefully it will work for you so try this The ajax function: Edit: Hope it helps option in my
and DataTable are showing the 10 frist row with defa
$('#example tbody').on( 'change', 'select[name="your_select_name"]',function(){
var data = '';
data = example.row( $(this).parents('tr') ).data();
var clientid = data['your column name'];
var selectId = this.value;
console.log(clientId);
console.log(selectedId);
//if id is okay do an ajax call inside a function something like this
if(clientid != undefined){
ajaxCallBack(clientId,selectedId)
.done(function(response){
//your update response here
})
}
})
function ajaxCallBack(clientId,selectId){
return $.ajax({
method: "POST",
url: "YourUrl",
data: { action: "UPD", clientId: clientId, selectId: selectId}
})
}
Your datatable should be declared like this:
var example= $('#example').DataTable({
"destroy": true,
"responsive":{
"details": {
renderer: function ( api, rowIdx, columns ) {
var data = $.map( columns, function ( col, i ) {
return col.hidden ?
'
'+
' ' :
'';
} ).join('');
return data ?$(''+col.title+':'+' '+
''+col.data+' '+
'').append( data ) :false;
}
}
},
"autoWidth": false,
"ajax": {
"url": 'some.php',
"method": 'POST',
data:{accion:"SLC"}
},
"columns": [
{"data": "client"},
{"data": "name"},
{"data": "lastname"},
{"data": "device"},
{"data": "city"},
{
className: "center",
defaultContent:""
}
],
"language":{"url": "//cdn.datatables.net/plug-ins/1.10.15/i18n/Spanish.json"},
"columnDefs": [
{
"className": "dt-center", "targets": "_all"
}
]
}
);