Automatically calculate the number of rows that fit on the page

Automatically calculate the number of rows that fit on the page

delpydelpy Posts: 3Questions: 0Answers: 0
edited May 2013 in General
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.

Replies

  • delpydelpy Posts: 3Questions: 0Answers: 0
    Any help? Has someone solved this problem before?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Currently no - I'm not aware of any open source code that solves this situation. However, I'd say that the solution is more or less exactly as you say - calculate the available area and then change the scrolling container height.

    Allan
  • delpydelpy Posts: 3Questions: 0Answers: 0
    Hi Allan, thanks for your help. I'll keep plugging away and post a solution once I find one.
This discussion has been closed.