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

  • Home
  • SEARCH
  • 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 6998695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:26:38+00:00 2026-05-27T20:26:38+00:00

I am dynamically generating rows of a table from the ajax response I am

  • 0

I am dynamically generating rows of a table from the ajax response I am getting. The table headers are static/constant. I am finally writing this to a div on a page.

The div has both horizontal and vertical scroll. My issue is this: If say I have 100 rows I can’t see the headers/table columns. I want to make it like freeze pane in excel, where you can see the headers/columns.

I tried separating the headers/columns from the rows but the issue I face is wide, i.e. the row td size doesn’t match up to the headers. Here’s my code (sample code):

I want to make it work in IE7 and Firefox.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> Some Page </title>
       <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>

     <body>
      <div id="dataDiv" style="white-space:nowrap; overflow-y:scroll; height:330px;overflow: scrollbars-vertical;overflow-x:scroll; width:100%;overflow: scrollbars-horizontal;">
     </body>
    </html>


    <script>


    function ProcessResponse(ajaxResponseData) 
    {

        var dataList = ajaxResponseData.somDataList;



        if(dataList != null)
        {

            var rowData = "<table border='1'  width=1200px>";
            rowData += "<tr>"           
                + "<td colspan='6'><b>Header1</b></td>"
                + "<td colspan='4'><b>Header2</b></td>"
                + "<td colspan='4'><b>Header3</b></td>"
                + "<td colspan='4'><b>Header4</b></td>"
                + "<td colspan='4'><b>Header5</b></td>"
                + "<td colspan='4'><b>Header6</b></td>"
                + "<td colspan='4'><b>Header7</b></td>"
                + "<td colspan='4'><b>Header8</b></td>"
                + "<td colspan='4'><b>Header9</b></td>"
                + "<td colspan='4'><b>Header10</b></td>"
                + "<td colspan='4'><b>Header11</b></td>"
                + "<td colspan='4'><b>Header12</b></td>"
                + "<td colspan='4'><b>Header13</b></td>"
                +"</tr>";




            for(var i=0;i<dataList.length;i++)
            {
                var someRowData=new Object();
                someRowData = dataList[i];


                rowData+="<tr>"             
                +"<td colspan='6'>"
                +someRowData.Header1_data+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
                +"</td><td colspan='4'>"
                +someRowData.Header2_data
                +"</td><td colspan='4'>"
                +someRowData.Header3_data
                +"</td><td colspan='4'>"
                +someRowData.Header4_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header5_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header6_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header7_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header8_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header9_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header10_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header11_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header12_data
                +"</td>" 
                +"</td><td colspan='4'>"
                +someRowData.Header13_data  
                +"</tr>";
            }
            rowData+="</table>";


            var dataDiv=document.getElementbyId("dataDiv");

            if(dataList.length == 0)
            {

                dataDiv.innerHTML="";
            }   
            else    
            {           
                dataDiv.innerHTML=rowData;
            }   

        }

    }
    </script>

Please help. Your help will be appreciated. Thanks

  • 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-27T20:26:38+00:00Added an answer on May 27, 2026 at 8:26 pm

    What you need to do is set overflow: auto; to the tbody element rather than your div (and keep your th elements in a thead element). This won’t work (without some tweaking/hacking) in anything but Firefox though (maybe Opera as well – not sure). Check the link @smnbss provided and you should probably solve it. The biggest problem is that you have to set fixed width’s to all your cells if you want it to work in all the browsers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for reading this. I am dynamically generating some data which includes a select
For my webpage, I have a number of lists which I'm generating dynamically from
i'm generating controls dynamically on my asp.net page by xslt transformation from an xml
I'm generating buttons dynamically that I want it to call a method like this:
I have a page that is currently generating dynamically created textboxes in a table
I created rows of table Dynamically by jquery, I also add a remove button
I need a bit help with dynamically generating column-based table instead of row-based table.
I am dynamically generating a function and assigning it to a class. This is
I'm dynamically generating RDL files for SSRS 2008, assembling my reports from building blocks
I am dynamically generating a table to present some tabular data. Normally I would

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.