default row selected

2 posts, 0 answers
  1. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 15 Dec 2009 Link to this post

    I have a Radgrid with a GridClientSelectColumn.  I need to default the header and all row checkboxes to checked = true. 

    Thanks in advance.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Dec 2009 Link to this post

    Hello ,

    You can access the client id of the header checkbox from code behind and store in a HiddenField. Then you can use the following code in the onGridCreated client event of the grid, to check all the row checkboxes and the header checkbox by default:
    c#:
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridHeaderItem) 
            { 
                GridHeaderItem header = (GridHeaderItem)e.Item; 
                string clientid = ((CheckBox)header["ClientSelectColumnUniqueName"].Controls[0]).ClientID; 
                HiddenField1.Value = clientid; 
            } 
        } 

    js:
      function GridCreated()  
        {      
           var grid = $find("<%=RadGrid1.ClientID %>"); 
           grid.MasterTableView.selectAllItems(); 
           var hiddenfield = document.getElementById("HiddenField1");  
           var control = document.getElementById(hiddenfield.value);  
           control.checked = true;   
        }  

    Hope this helps..
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top