Selecting multiple rows when using XMLHttpRequest
Selecting multiple rows when using XMLHttpRequest
sbarnett
Posts: 23Questions: 5Answers: 0
Hi,
I have a REST server which will return all my data in one go for the DataTable I want to draw.
I fetch the data using XMLHttpRequest and when it comes back, I initialise my table with the returned data.
I want to be able to select multiple rows on this table but it doesn't seem to matter where I put the instruction to add (or remove) the row_selected class, it won't let me select more than one.
Here is my code:-
[code]
$(document).ready(function() {
$('#example tr').click( function() {
if ( $(this).hasClass('row_selected') )
$(this).removeClass('row_selected');
else
$(this).addClass('row_selected');
} );
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
$('#example').dataTable( {
"aoColumns": [ null,
null,
null,
null,
null,
null ],
"bAutoWidth": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"aaData": eval(xmlhttp.responseText)
} );
}
}
xmlhttp.open("GET","http://localhost/rest_server",true);
xmlhttp.send();
Col1
Col2
Col3
Col4
Col5
Col6
[/code]
I have a REST server which will return all my data in one go for the DataTable I want to draw.
I fetch the data using XMLHttpRequest and when it comes back, I initialise my table with the returned data.
I want to be able to select multiple rows on this table but it doesn't seem to matter where I put the instruction to add (or remove) the row_selected class, it won't let me select more than one.
Here is my code:-
[code]
$(document).ready(function() {
$('#example tr').click( function() {
if ( $(this).hasClass('row_selected') )
$(this).removeClass('row_selected');
else
$(this).addClass('row_selected');
} );
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
$('#example').dataTable( {
"aoColumns": [ null,
null,
null,
null,
null,
null ],
"bAutoWidth": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"aaData": eval(xmlhttp.responseText)
} );
}
}
xmlhttp.open("GET","http://localhost/rest_server",true);
xmlhttp.send();
Col1
Col2
Col3
Col4
Col5
Col6
[/code]
This discussion has been closed.