1
I am listing information from my database in a datatable with jQuery and so far everything is ok.
What I want to do is by clicking on the 'Row' from Datatable
click on that div all the information of that ID that was shown in the table. An example of what I want to do is type the gmail that appears the emails in list form and when the person clicks it.
How can I do this with a Datatable?
I’m displaying 10 items on the first page of the table and when I click on the row, it displays the row I want. The problem is when I go to the second or third page and click on the line the Javascript Alert does not work.
$(function() {
var oTable = $("#tabelaaberto").dataTable({
"oLanguage": {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Exibindo de _START_ até _END_ no total de _TOTAL_ registros.",
"sInfoEmpty": "",
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado.",
"sSearch": "Pesquisar: ",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
}
});
$(document).ready(function(e) {
$("#tabelaaberto tbody td").on('click',function(){
var nTr = $(this).parents('tr')[0];
var aData = oTable.fnGetData(nTr);
alert(aData[0]);
});
});
});
I’m sure you’ll have to write some
JavaScript
to detect click and useAjax
to upload new data on demand. Are you familiar with this? In your question, you failed to paste the example link.– Caffé
@brasofilo is not duplicate as this question is specifically about the Datatables plugin
– user7261
Please include the code of what you have managed to do so far. You are mounting all the
<table>
and then Initiating the plugin? Or is using the option to pull the data by AJAX?– user7261