Apply changes on all the hidden rows in datatable legacy (1.9)
Apply changes on all the hidden rows in datatable legacy (1.9)
I have table with number of records where one of the columns is having a dropdown list. Based on the value in one of the columns the options/values in the select needs to be removed. I am able to do this, but the changes are applied to the first set of records that are shown on the screen. The rest of the records in the other pages of the table is not affected. I initially used the following syntax to access the table data
$('table tr').each(function(){...});
Since the above code is not fetching the hidden rows, I used the fnGetNodes() to access the all the rows. Following is the complete code to access and modify the contents.
var rows=oTable.fnGetNodes();
for(var i=0;i<rows.length;i++){
var index=5;
var grade=$(rows[i]).find('td').eq(index).text();
var desc=$(rows[i]).find('td').eq(index+1).text();
console.log('Grade - '+grade);
console.log('Desc - '+desc);
index=13;
var selID=$(rows[i]).find('td').eq(index).find('select').attr('id');
if(grade.match('Used')){
$("select#"+selID).attr('disabled', true);
$("select#"+selID).css("background-color","#eeeeee");
}
else if(desc.match('ALT$') || desc.match('MTM$'))
{
$("#"+selID+" option[value='Option one']").remove();
}
}
http://live.datatables.net/tugivusi/1/
I am able to print the id of the select element, but not able to change it. Its again working for the first set of records shown on the screen and not for the hidden ones. Can you please let me know what I am missing?