2016-12-07 3 views
0

У меня возникают некоторые странные проблемы с моим статическим заголовком GridView. Строки в IE не выстраиваются правильно; некоторые из них делают, а другие нет. Кто-нибудь может мне помочь? Он отлично работает в Chrome, а не в IE.Проблемы с Internet Explorer Static GridView

Chrome: Chrome

IE: IE

Вот мой соответствующий код.

<script type="text/javascript"> 
        function MakeStaticHeader(gridId, height, width, headerHeight, isFooter) { 
         var tbl = document.getElementById(gridId); 
         if (tbl) { 
          var DivHR = document.getElementById('DivHeaderRow'); 
          var DivMC = document.getElementById('DivMainContent'); 
          var DivFR = document.getElementById('DivFooterRow'); 

          //*** Set divheaderRow Properties **** 
          DivHR.style.height = headerHeight + 'px'; 
          DivHR.style.width = (parseInt(width) - 50) + 'px'; 
          DivHR.style.position = 'relative'; 
          DivHR.style.top = '0px'; 
          DivHR.style.left = (tbl.clientLeft-25) +'px'; 
          DivHR.style.zIndex = '10'; 
          DivHR.style.verticalAlign = 'top'; 
          DivHR.style.alignContent = 'center'; 

          //*** Set divMainContent Properties **** 
          DivMC.style.width = width + 'px'; 
          DivMC.style.height = height + 'px'; 
          DivMC.style.position = 'relative'; 
          DivMC.style.top = -headerHeight + 'px'; 
          DivMC.style.zIndex = '1'; 
          //****Copy Header in divHeaderRow**** 
          DivHR.appendChild(tbl.cloneNode(true)); 
         } 
        } 



        function OnScrollDiv(Scrollablediv) { 
         document.getElementById('DivHeaderRow').scrollLeft = Scrollablediv.scrollLeft; 
         //if (document.getElementById('DivHeaderRow').scrollLeft >= 300) { 
         // document.getElementById('DivHeaderRow').scrollLeft = 300; 
         //} 
        } 

       </script> 

CSS

html, body { 
    margin:0px; 
    padding:0px; 
    width: 100%; 
    box-sizing: border-box; 
} 

CSS Заголовок Стиль

.GVFixedHeader 
    { 
     font-weight: bold; 
     background-color: Green; 
     position: relative; 
     font-size: 12px; 
     text-align: left; 
    } 

ответ

0

Это связано с тем, как IE оказывает GridView. Я бы поменял свое формирование на одной ячейке таблицы, но это может испортиться с IE и изменить настройки по умолчанию. Chrome правильно определил бы, что я только хотел добавить стиль, который не изменяется полностью.

for (int i = 0; i < e.Row.Cells.Count; i++) 
       { 
        if (e.Row.RowType == DataControlRowType.Header) 
        { 
         e.Row.Cells[i].Attributes.Add("style", "white-space: inital;"); 
         e.Row.Cells[i].Attributes.Add("style", "text-align: left;");//THIS IS WHAT I ADDED + some altering of the width of the JS 
         if (i == 1) 
         { 
          e.Row.Cells[i].Text = "Make Inactive?"; 
         } 
         if (i == 9) 
         { 
          e.Row.Cells[i].Text = "Total Invoice YTD"; 
          e.Row.Cells[i].Attributes.Add("style", "white-space: normal;"); 
         } 
         if (i == 13) 
         { 
          e.Row.Cells[i].Attributes.Add("style", "white-space: normal;"); 
         } 
        } 
        if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;"); } //ALWAYS makes sure there is no wrapping of text 
       } 
Смежные вопросы