get data from table
get data from table
I dont know get data from table. I use ajax and php for load data from mysqkdatabase. I use paginatoion and filtering too. But I domt know get data from table. I dont have any idea for variabel to use for get data from any field by click in row.
<script>
$(document).ready(function() {
$('#datatable').DataTable({
ordering: false,
searching: true,
processing: true,
serverSide: false,
ajax: 'php-list-zakaznik.php',
dataSrc: 'data',
columns: [
{ data: 'zak_id' },
{ data: 'zak_nazov' },
{ data: 'zak_ulica' },
{ data: 'zak_mesto' },
{ data: 'zak_icdph' },
{ data: 'zak_tel1' },
{ data: 'zak_tel2' },
{ data: 'zak_email' },
{ data: 'zak_poznamka' }
],
columnDefs: [
{
targets: [ 0 ],
visible: false,
searchable: false
}
],
});
// Click on row
$('#datatable tbody').click( function () {
var table =
alert( "salary is: ");
});
});
</script>
How I can have data for example first hidden column ID when I click in to table row, please?
Thanks a lot.
PS: your example with otable doesnt work for me.
Or can anybody post full example for this:
- load data from MySQL database
- fucntion filtering, pagination, translating for table
- last row with button
- click on button - open dialog with form for change all values in clicked row and save button
- store all these row updated datas in to datatabase
- refresh table with new updated datas.
Thanks, thanks, thanks....
Answers
I think what you are looking for is Editor. If you do not currently have Datatables Editor, you will either have to purchase that or build your own editor. I highly recommend Datatables Editor.
You don't need Editor to get the data from a DataTable (although don't let me stop you buying it ).
row().data()
should be all that you need:A few things to note:
table
as I have done in line 2 abovetr
elements, not the tbodyzak_id
, but change as you need.Allan