single row selectioon

single row selectioon

Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
edited January 2014 in General
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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you link to a test page showing the issue, as required in the forum rules please.

    My guess is that there isn't a `tbody` element present in the table when you initialise the DataTable.

    Allan
  • Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
    Here is the folder

    \\10.32.23.95\exampledatatable

    Thanks!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > Oops! Google Chrome could not connect to 10.32.23.95

    Sorry :-(
  • Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
    I've just wrote that in Chrome
    file://10.32.23.95/exampledatatable/
    and I got access to my files....
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > file://

    Can you put it up on the public internet so I can access it as well?

    Allan
  • Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
    https://drive.google.com/file/d/0BzHS24RBHlSqZW9SdURWQlhzbm8/edit?usp=sharing

    However is public, you would not need this link (I mean, I uploaded the files in google drive)
  • Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
    https://drive.google.com/file/d/0BzHS24RBHlSqa1BhTEdnZTktWTQ/edit?usp=sharing
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I would rally be best is you could use js fiddle or similar to post a test case that I can debug.

    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
  • Chiqui7988Chiqui7988 Posts: 13Questions: 0Answers: 0
    Allan, first of all, thanks for your answers. This example of mine works fine but I can't get the effect of row selection. In fact, I can't - neither - get the row highligthing with css effect, I mean, I got the first column "illuminated" but not the others. You know, I note that the html returns something like that
    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
This discussion has been closed.