Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:37:27+00:00 2026-05-25T22:37:27+00:00

I am using jquery data table for displaying data. On body onload its sets

  • 0

I am using jquery data table for displaying data. On body onload its sets height using following code

<table id="RequestsTable" cellpadding="0" cellspacing="0" border="0" class="display" style="width:100%;">

In script i have write down following code.
ScrollY calculates height base on window height and assign to data table on form load.

<script type="text/javascript">
var scrollY = $(window).height()*58/100;

var oTable = $('#RequestsTable').dataTable({
    "sScrollY": scrollY,
    "bPaginate": true,
    "bScrollCollapse": true,

    } );

I want to calculate height again when window resize and assign to data table.
I have tried following code but not worked for me.

var scrollY = $(window).height()*58/100;    
$(window).resize(function () {  
scrollY = $(window).height()*58/100;
});

    var oTable = $('#RequestsTable').dataTable({
        "sScrollY": scrollY,
        "bPaginate": true,
        "bScrollCollapse": true,

        } );

anybody have any idea ow can implement this.
Thanks in advance.

I tried this but no luck

function calcDataTableHeight () {
    return $(window).height()*58/100;
};

$(window).resize(function () {

   var oSettings = oTable.fnSettings();
    oSettings.sScrollY = calcDataTableHeight();
    oTable.fnDraw();
});

var oTable = $('#reqAllRequestsTable').dataTable({
    "sScrollY": calcDataTableHeight()});

Any other way is possible to set height using css ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:37:28+00:00Added an answer on May 25, 2026 at 10:37 pm

    It isn’t sufficient to update the variable, you need to pass the new height to the datatable plugin (as it doesn’t update automatically when the variable’s content changes):

    var $window = $(window);
    
    var calcDataTableHeight = function() {
        return Math.round($window.height() * 0.58);
    };
    
    var oTable = $('#RequestsTable').dataTable({
        "sScrollY": calcDataTableHeight(),
        "bPaginate": true,
        "bScrollCollapse": true,
    });
    
    $window.resize(function() {
        var oSettings = oTable.fnSettings();
        oSettings.oScroll.sY = calcDataTableHeight(); // <- updated!
    
        // maybe you need to redraw the table (not sure about this)
        oTable.fnDraw(false);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building some <table> data dynamically using jQuery, but I'm getting the following error:
I am using the JQuery DataTables plugin for displaying large sets of data. One
I'm using jQuery to drive my AJAX UI. I have a table of data,
using jquery I need to retrieve an array from table cells, format the data
I'm developing code using jQuery and need to store data associated with certain DOM
I'm using jQuery $.ajax to load my table row data like <table id='row-data'> <tr><td>1001</td></tr>
I'm using jQuery DataTable to form a table out of this data.txt: { aaData
I am having some problems creating custom types for my data table, using jquery.datatables.js.
I'm trying to save data from HTML table to database using jquery to call
I'm posting data using jquery/ajax and PHP at the backend. Problem being, when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.