3
In jquery datatable how do I select a single row and get the value of a certain column, such as id?
3
In jquery datatable how do I select a single row and get the value of a certain column, such as id?
1
With this code you will get the contents of the column:
$('th').click(function(){
alert($(this).html());
});
You just have to adapt your need.
0
In your Jsfiddle code just change the on-click event from the button to this:
$('#btnGetId').click( function () {
alert($('#example tr.selected').children(':first-child').html());
} );
What you are doing in this case is taking the existing value inside the first column, but this can vary quite a lot.
Could you put the id of the line (tr) with the value of the id field and could take as follows:
$('#btnGetId').click( function () {
alert($('#example tr.selected').attr('id'));
} );
Getting safer, because if you change the order of the columns your id will continue searching from the same place.
Or add a specific class to the id column and you can recover it like this:
$('#btnGetId').click( function () {
alert($('#example tr.selected').children('.id').html());
} );
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
You can put the code here, or join an example in jsFiddle for example?
– Sergio
http://jsfiddle.net/miguelpacifico/4jjkrqew/
– Miguel Pacifico