Function to make a dataTable scroable and the row number will be set by the value of a hidden field
function updateScrollableTableHeight() {
"use strict";
$('.ui-datatable-scrollable:visible').each(function () {
var maxRowsElement = $("[id='" + $(this)[0].id + '_rowsToDisplay' + "']");
var maxRows = 0;
if (maxRowsElement.length > 0){
maxRows = parseInt($(maxRowsElement)[0].innerText);
}
if (maxRows != 0){
var bodySize = 0;
var tableRows = $(this).find("tbody").find("tr")
if (tableRows.length > maxRows){
for (var i = 0; i < maxRows; i++){
bodySize += $(tableRows[i]).height();
}
}
if (bodySize != 0){
$(this).find('.ui-datatable-scrollable-body').css({"max-height": bodySize + "px"})
}
}
});
}