Change background color of row while looping though rows
Change background color of row while looping though rows
I am new to data tables so please excuse this is a silly question. I have a table which I need to run through all rows and call $.getJSON() on each row. As I do this I would like to change the background color to show that row is being processed (say red) and then completed (say green).
I think the code below is a reasonable way to do this - if there is a better way Im open to suggestions
AND is there a way to delay the return from the JSON call to ensure that it completes processing before changing colour.
Thank you for any help.
function processRows() {
var oTable = $('#batchDataTable').dataTable();
var noColumns = oTable.fnSettings().aoColumns.length
for (var r = 0; r < rows.length; r++) {
var id = oTable.fnGetData(r, noColumns - 1); // unique id is in last column
var url = '/run_batch?rowId=' + id; // URL call to process
$('#batchDataTable tbody tr:eq(' + r + ')').css("backgroundColor", "red");
$.getJSON(url,function (data) {
});
$('#wasp_strategiesBatchDataTable tbody tr:eq(' + r + ')').css("backgroundColor", "green");
}
}
}
I think the code below is a reasonable way to do this - if there is a better way Im open to suggestions
AND is there a way to delay the return from the JSON call to ensure that it completes processing before changing colour.
Thank you for any help.
function processRows() {
var oTable = $('#batchDataTable').dataTable();
var noColumns = oTable.fnSettings().aoColumns.length
for (var r = 0; r < rows.length; r++) {
var id = oTable.fnGetData(r, noColumns - 1); // unique id is in last column
var url = '/run_batch?rowId=' + id; // URL call to process
$('#batchDataTable tbody tr:eq(' + r + ')').css("backgroundColor", "red");
$.getJSON(url,function (data) {
});
$('#wasp_strategiesBatchDataTable tbody tr:eq(' + r + ')').css("backgroundColor", "green");
}
}
}
This discussion has been closed.