Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
745
Access checkbox of ItemTemplateColumn through javascript - firefox
posted

Hello,

I'm using Infragistics v12.1.

I have a webdatagrid like this:

<ig:WebDataGrid EnableDataViewState="true" ID="wdgPorAlocar" runat="server" Height="100%" Width="100%" AutoGenerateColumns="False" EnableAjax="False" ShowFooter="true">   

<Columns>      

<ig:TemplateDataField Key="Alocar_" Width="20px">         

    <HeaderTemplate>  
       <div style="text-align: left;">               
            <input type="checkbox" onclick="checkAll1(event);" />            
       </div>         
    </HeaderTemplate>         
    <ItemTemplate>       
        <div style="text-align: left;">               
             <asp:CheckBox ID="Key_" runat="server" Checked='<%# Eval("Alocar") %>' />            
        </div>       
     </ItemTemplate>      

</ig:TemplateDataField>      

...    

</Columns>   

<ClientEvents Initialize="intializeGrid1" ="intializeGrid1" />   
<Behaviors>       ...  </Behaviors>

</ig:WebDataGrid>

 

 

Here's the javascript code:

<script type="text/javascript">

        var webDataGrid1;

        function intializeGrid1(grid) {            
            webDataGrid1 = grid;        
        }

        function checkAll1(evnt) {

            var chkBox = evnt.target ? evnt.target : evnt.srcElement;

            for (var i = 0; i < webDataGrid1.get_rows().get_length(); i++) {                
                webDataGrid1.get_rows().get_row(i).get_cellByColumnKey("Alocar_").get_element().all(0).all(0).checked = chkBox.checked;            
            }        
         }

 </script>

When I click the header checkbox of column "Alocar_" I want all the checkbox of the grid rows to be selected. This works fine in IE. But it doesn't work on firefox, it says that webDataGrid1.get_rows().get_row(i).get_cellByColumnKey("Alocar_").get_element().all is not a valid funcion. How can I achieve this in firefox?

Thank you

 

  • 745
    Verified Answer
    posted

    Never mind. I've already found a solution.

    Instead of using webDataGrid1.get_rows().get_row(i).get_cellByColumnKey("Alocar_").get_element().all(0).all(0).checked

    I can use

    webDataGrid1.get_rows().get_row(i).get_cellByColumnKey("Alocar_").get_element().childNodes(1).childNodes(1).checked

    And it works fine in both browsers.

    Thanks anyway