Select all checkboxes from GridTemplateColumn (clientside)

2 posts, 0 answers
  1. James Shelton-Agar
    James Shelton-Agar avatar
    108 posts
    Member since:
    May 2008

    Posted 12 Jan 2010 Link to this post

    Hi, I am trying to have a button to select all checkboxes from client side.
    Grid
    <telerik:GridTemplateColumn UniqueName="Features"
                                <ItemTemplate> 
                                    <div id="resultList"
                                        <asp:CheckBox ID="checkTag" CssClass="mapcheck" runat="server" AutoPostBack="True" 
                                            OnCheckedChanged="CheckTag_CheckedChanged" /> 
     
                                    <div> 
                                        <%#Eval("DisplaySearchRef")%> 
                                    </div> 
                                </ItemTemplate> 
                                <HeaderStyle Width="100%" /> 
                            </telerik:GridTemplateColumn> 

    JS
      for (var i = 0; i < masterTable.get_dataItems().length; i++) { 
                                var gridItemElement = masterTable.get_dataItems()[i].findControl("checkTag"); 
                                if (gridItemElement != null) { 
                                    alert('ok'); 
                                    gridItemElement.checked = true
                                }                             
                            } 

    which doesn't seems to work, any idea?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2010 Link to this post

    Hi James,

    I used 'findElement()' method instead of 'findControl' and I am able to access the checkbox. See the code that I tried.
    JavaScript:
     
        function selectAll() { 
            var grid = $find("<%=RadGrid1.ClientID %>"); 
            var masterTable = grid.get_masterTableView(); 
            for (var i = 0; i < masterTable.get_dataItems().length; i++) { 
                var gridItemElement = masterTable.get_dataItems()[i].findElement("checkTag")
                if (gridItemElement != null) { 
                    gridItemElement.checked = true
                } 
            } 
        } 

    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top