Re: A style sheeting resolution to fixed column headers in a datagrid

  • From: "black ares" <matematicianu2003@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 30 Jul 2010 13:46:48 +0300

look, now I found time to write largely on this subject.
First of all we need a javascript function/script like the one below.
Second we need 2 divs, like the other after the javascript.
Third in code behind, the style of the grid must be set to table-layout:fixed.
I will show in the lines bellow my solution:
1. javascript:
<script type=”text/javascript”>
    function s()
    {
        var t = document.getElementById(”<%=GridView1.ClientID%>”);
        var t2 = t.cloneNode(true)
        for(i = t2.rows.length -1;i > 0;i–)
        t2.deleteRow(i)
        t.deleteRow(0)
        a.appendChild(t2)
    }
    window.onload = s
    </script>

2. Html code:
    <div id=”a”>
    </div>
    <div style=”overflow-y: scroll; height: 200px”>
    <asp:GridView ID=”GridView1″ runat=”server” Font-Size=”12px” 
BackColor=”#FFFFFF”
    GridLines=”Both” CellPadding=”4″ Width=”560″>
    <HeaderStyle BackColor=”#EDEDED” Height=”26px” />
    </asp:GridView>
    </div>

3. code behind, in page load:
                GridView1.Attributes.Add(”style”, “table-layout:fixed”);

that is all.
Most important is that style of table-layout: fixed.
Because with out it the table and headers don't allign them selves.
best Regards
Black Ares


  ----- Original Message ----- 
  From: Jacob Kruger 
  To: Program-l 
  Cc: ProgrammingBlind@xxxxxxxxxxxxx 
  Sent: Friday, July 30, 2010 10:22 AM
  Subject: A style sheeting resolution to fixed column headers in a datagrid


  This is soooo simple, quick and easy - will now just have to ask the sighted 
guys how well it works:
  http://www.codeproject.com/KB/webforms/DataGridFixedHeader.aspx

  All I needed to have done is use the right search terms etc. - helps to call 
them fixed instead of static column headers, and, FWIW, my search terms for 
google's accessible search were as follows:
  codeproject aspx fixed column headers

  Stay well

  Jacob Kruger
  Blind Biker
  Skype: BlindZA
  '...fate had broken his body, but not his spirit...'



  __________ Information from ESET NOD32 Antivirus, version of virus signature 
database 5324 (20100729) __________

  The message was checked by ESET NOD32 Antivirus.

  http://www.eset.com

Other related posts: