Skip to content Skip to sidebar Skip to footer

Ie8 Doesn't Apply Css Display Dynamically

I'm trying to develop a table that hides its columns upon a given value. I am using a solution discussed in another SO question. As part of the suggestion there they say that to s

Solution 1:

It sounds like it's not repainting the table. There are several IE 7 & 8 repaint and reflow oddies out there...

You can try forcing the repaint in your javascript, maybe just by hiding and showing the table with something like

document.getElementById('myTable').style.display='none';
document.getElementById('myTable').style.display='table';

or forcing a reflow on the entire page with something like

document.body.className=document.body.className;

Solution 2:

It appears that there is a problem when trying to repaint the cells. Just from the CSS rule doesn't work but if we apply the display directly in the JavaScript then the cells are drawn properly. Looping trough the cells and applying the style directly works, I just had to have a name convention to easily identify the class that a cell is supposed to be.

if(isEmpty(cell.className)|| cell.className == (selectedType+"_cell"))
    {    
      cell.style.display = 'table-cell'; // might be different for other IE versions
    }
    else
    {
        cell.style.display = 'none';
    }

Post a Comment for "Ie8 Doesn't Apply Css Display Dynamically"