Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Fixed Table Header and changing classes

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey folks.

First time poster, be gentle with me.

I am currently having an issue with an internal webiste that has been causing me considerable grief.

I have tables with fixed header rows that are working well, with one very irritating exception.

We use an method on our text boxes to perform validation.

If the field has an error, we change the color of the text box to represent this. If the field is fine, we set it to the original color it was before we flagged it as an error. Pretty normal, right?

Well, this is when things get interesting. If the user scrolls down any amount in the table, and then clicks in and then out of the field, triggering the onblur, the fixed header jumps right out of the table. It's as if the top value is being set to where it WOULD have been in the table had the position not been set to relative. Further scrolling will not move the header from it's position on the page, until the onblur triggers again, with the header moving to a different position.

The problem is not with the onblur event or the text boxes. I have placed a button outside of the table and container div, and used it to cause the same problem by changing the class of a tr or td.

Some more background info before I post code.
  • 1 It only occurs in IE7. (The only browser I need to support.)
  • 2 I know a way to fix the problem using an expression involving scrollTop on the headerRow, but I'd like to avoid it for performance reasons.
  • 3 The table MUST be variable width.
  • 4 I absolutely need to set a class, and not set individual styles. I have 100+ pages that use the validation classes in the js validation routines.
  • 5 The outer table is only there to force the container div to be the width of the scrolling table.


  • Here's the code. Sorry for the size. Make sure to change onblurMeth to onblur before trying this sample.

     
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So when the browser redraws the element it forgets what it is doing.

    One thing to note is your code will not run in Firefox, look at this:

    http://www.imaputz.com/cssStuff/bigFourVersion.html

    Eric
     
    Joshua Ewart
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the reply, Eric.

    As I said, it appears as if IE forgets to reset the top position after the inner styles get updated.

    And it's an internal company website, so I only need to support IE7. Did you remember to change onblurMeth to onblur?

    Also, I have looked at that website multiple times. It does not appear to work in IE7.

    Again, thanks for taking the time to look at this.
     
    Eric Pascarello
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I looked at it and could not come up with anything.

    Eric
     
    Eric Pascarello
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    I had an idea today, you will have to live with a flicker



    Eric
     
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    the direct and correct method to resolve this issue is to use expression in css!
    if you use javascript to set the position of header when onscroll invoked, it would not run well as you expect.

    like
     
    Eric Pascarello
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Just a warning: Expressions in CSS can have very bad performance with IE.

    Eric
     
    Joshua Ewart
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Just a warning: Expressions in CSS can have very bad performance with IE.

    Eric



    Agreed. Which is why I'm making this change.

    Pretty nifty suggestion for that changeClassTest function, Eric.

    Unfortunately, I'm working with a VERY large dataset, and even if I cache the elements it's horrendously slow...
    Also, I'd need to modify all of my pages that are doing validation to implement it.

    Again, that's for the input. I just wish I need why changing the className was causing IE to flip the heck out...
     
    Eric Pascarello
    author
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You might be better off breaking your table into two. One for the header and one for the body. Add a scrollable div with a set height and stick your body table in that. You will either need to hard code the width values of the columns so they line up or use a JavaScript function to figure out the widths and adjust the columns.

    Eric
     
    You showed up just in time for the waffles! And this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic