single row selectioon
single row selectioon
Chiqui7988
Posts: 13Questions: 0Answers: 0
I am trying to select one row. I saw the example and I tried to do the same but it does not work for me. My code (that doesn't work fine) ...
$(document).ready(function() {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sRowSelect": "single"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "delservi.php",
"oLanguage": {
"sLengthMenu": "Desplegando _MENU_ registros por página",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Mostrando _START_ a _END_ de _TOTAL_ records",
"sInfoEmpty": "Exhibiendo 0 a 0 de 0 registros",
"sInfoFiltered": "(filtered from _MAX_ total records)"
},
"sPaginationType": "full_numbers"
} ),
$('#example tbody').on( 'click', 'td', function (e) {
equisml=$(this).parent().html();
i=equisml.indexOf('>');
j=equisml.indexOf('<',i);
var1=equisml.substring(i+1,j);
i=equisml.indexOf('">',j);
j=equisml.indexOf('<',i);
var2=equisml.substring(i+2,j);
alert("País seleccionado: "+var2); // 1er. td de la fila seleccionada
} );
}
);
By the way, the name "td_sorting_1" from where appears? And why the others columns does not have name (I mean, in the xml)
THANKS A LOT!!
el Chiquito
$(document).ready(function() {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sRowSelect": "single"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "delservi.php",
"oLanguage": {
"sLengthMenu": "Desplegando _MENU_ registros por página",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Mostrando _START_ a _END_ de _TOTAL_ records",
"sInfoEmpty": "Exhibiendo 0 a 0 de 0 registros",
"sInfoFiltered": "(filtered from _MAX_ total records)"
},
"sPaginationType": "full_numbers"
} ),
$('#example tbody').on( 'click', 'td', function (e) {
equisml=$(this).parent().html();
i=equisml.indexOf('>');
j=equisml.indexOf('<',i);
var1=equisml.substring(i+1,j);
i=equisml.indexOf('">',j);
j=equisml.indexOf('<',i);
var2=equisml.substring(i+2,j);
alert("País seleccionado: "+var2); // 1er. td de la fila seleccionada
} );
}
);
By the way, the name "td_sorting_1" from where appears? And why the others columns does not have name (I mean, in the xml)
THANKS A LOT!!
el Chiquito
This discussion has been closed.
Replies
My guess is that there isn't a `tbody` element present in the table when you initialise the DataTable.
Allan
\\10.32.23.95\exampledatatable
Thanks!
Sorry :-(
file://10.32.23.95/exampledatatable/
and I got access to my files....
Can you put it up on the public internet so I can access it as well?
Allan
However is public, you would not need this link (I mean, I uploaded the files in google drive)
However,:
> } ),
at the end of your DataTables initialisation. Is that not causing a syntax error?
What happens if you put a console.log() statement into the click handler? Does it show up in the console?
Allan
11Buenos Aires
As you can see, the first xml element is sorting_1 and the others are "". I don't know where the name sorting_1 came from but perhaps knowing how to name the others columns I could get the effect of row highlighting, but, I know, this is another question.
Thanks again
Ruben