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 8989791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:20:54+00:00 2026-06-15T22:20:54+00:00

I have an html table that I souped up to allow for sorting, resizable/movable

  • 0

I have an html table that I souped up to allow for sorting, resizable/movable columns, and a fixed header row. The fixed header caused a disconnect in the header cells and their corresponding content cells so that resizing the <th> did not resize the <td>'s in that column. As a work-around, I added some code to manually change the width of the content of the relevant <td> elements when the <th> is resized. It seems to work fine in most cases, but sometimes the column widths still don’t line up exactly. I used chrome dev tools to examine the html during one of the hiccups, and although the width style on both the <th> and <td> is the same, the actual width ( as returned by $(elt).width() ) was 3px less than the specified width for the <th>. Does anyone know what might cause this?

EDIT: I realized that this only happens when I resize the columns so that the total width of the table is larger than the parent div. The content cells overflow and allow me to scroll horizontally, but the <thead> stays its fixed width and adjusts some of the <th> elements smaller to compensate.

CSS:

.blotter {
    overflow-y: hidden;
    overflow-x: auto;
    position: relative;
    border-left: solid thin silver;
}

.blotter-table {
    table-layout: fixed;
    margin-bottom: -1px;
}

tbody {
    height: 400px;
    max-height: 400px; 
    overflow: auto;
}

thead>tr,tbody {
    display: block;
}

td>div {
    overflow: hidden;
}

Markup:

<div class="blotter">
    <table class="table table-bordered table-hover table-condensed blotter-table">
        <thead>
            <tr>
                <th id="tradeaggregation_numTrades" draggable="true" style="width: 422px; cursor: pointer; opacity: 1;"># Trades<img src="resources/img/down_arrow.png" class="pull-right" id="imgSort" style="opacity: 1; cursor: e-resize;"></th>
                <th id="tradeaggregation_listValues" draggable="true" style="width: 305px; cursor: pointer; opacity: 1;">List Values</th>
                <th id="tradeaggregation_mgmtId" draggable="true" style="width: 66px; opacity: 1; cursor: e-resize;">mgmtId</th>
                <th id="tradeaggregation_sizeSum" draggable="true" style="width: 78px; cursor: pointer; opacity: 1;">Size Sum</th>      
            </tr>
        </thead>
        <tbody>         
            <tr id="tradeaggregation0">             
                    <td><div id="tradeaggregation0_0" style="overflow: hidden; width: 422px;">8,113</div></td>              
                    <td><div id="tradeaggregation0_1" style="overflow: hidden; width: 305px;">4RAJA-SUN null </div></td>                    
                    <td><div id="tradeaggregation0_2" style="overflow: hidden; width: 66px;">10,831,124,369</div></td>                  
                    <td><div id="tradeaggregation0_3" style="overflow: hidden; width: 78px;">19,048,548</div></td>                  
            </tr>
        </tbody>
    </table>
</div>
  • 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-06-15T22:20:55+00:00Added an answer on June 15, 2026 at 10:20 pm

    Let me first clarify exactly the behavior I was looking for. I needed a table that would allow scrolling vertically of the tbody overflow while having a fixed thead. In addition, columns could be resized, and if the total size of the columns causes the table to become wider than the parent container, the overflow should be scrollable horizontally rather than adjusting the column widths to stay within their parent width constraints. That being said, I accomplished it using my markup/css from above, but I used javascript to explicitly increase the width of the table when a column is resized such that the total width of the columns is now greater than the viewing area.

    var cols = this.$el.find("tbody>tr:first td");
    var newWidth = 1;
    for ( var i = 0; i < cols.length; i++) {
        newWidth += $(cols[i])[0].offsetWidth;
    }
    var minWidth = $(this.$el.find(".blotter")[0]).width(); // parent div
    if (newWidth < minWidth) newWidth = minWidth;
    this.$el.find("table").width(newWidth);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html table that always shows its header columns, when the user
I'm trying to have a simple html table, that highlights a row as a
I have an html table that includes 7 columns. Data is pulled from an
I have an html table that literally has like 30 columns of data, and
I have an html table that displays maintenance records. There are 3 columns that
I have an html table that is displaying customer orders. One of these columns
I have an HTML table that I'm sorting with jQuery tablesorter. I have an
OK, I am stumped. I have an HTML table that is within a fixed
I have a html table that has 2 cells in a row. How can
I have an HTML table 2x2. In that table, I want the first row

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.