Automatically calculate the number of rows that fit on the page
Automatically calculate the number of rows that fit on the page
Sorry if this has been discussed elsewhere but I could not find the solution.
I want to calculate an appropriate iDisplayLength at runtime based on the number of rows that fit on the page. Something along the lines of:
[code]
floor((tableHeight - headerHeight - footerHeight) / rowHeight)
[/code]
I've played with setting the table style to 100% but this just autofills to the end of the page with the preset iDisplayLength.
Currently, my code sets iDisplayLength in the default options:
[code]
DataTableUtils.getDefaultOptions = function() {
var options;
options = {
iDisplayLength: 32,
bAutoWidth: false,
bJQueryUI: true,
bSort: false,
bFilter: false,
bProcessing: true,
bServerSide: true,
sAjaxSource: 'notUsed',
sDom: 't<"F"rip>',
sScrollY: '900px',
oLanguage: {
sLengthMenu: '_MENU_'
},
sPaginationType: 'full_numbers'
};
return options;
};
[/code]
Edit: This is for a custom GUI that renders and navigates between local htm pages. It is not available online. I ask this question more to see if this is possible and how it would be done. Please let me know if you require more details.
I want to calculate an appropriate iDisplayLength at runtime based on the number of rows that fit on the page. Something along the lines of:
[code]
floor((tableHeight - headerHeight - footerHeight) / rowHeight)
[/code]
I've played with setting the table style to 100% but this just autofills to the end of the page with the preset iDisplayLength.
Currently, my code sets iDisplayLength in the default options:
[code]
DataTableUtils.getDefaultOptions = function() {
var options;
options = {
iDisplayLength: 32,
bAutoWidth: false,
bJQueryUI: true,
bSort: false,
bFilter: false,
bProcessing: true,
bServerSide: true,
sAjaxSource: 'notUsed',
sDom: 't<"F"rip>',
sScrollY: '900px',
oLanguage: {
sLengthMenu: '_MENU_'
},
sPaginationType: 'full_numbers'
};
return options;
};
[/code]
Edit: This is for a custom GUI that renders and navigates between local htm pages. It is not available online. I ask this question more to see if this is possible and how it would be done. Please let me know if you require more details.
This discussion has been closed.
Replies
Allan