This is a migrated thread and some comments may be shown as answers.

default row selected

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gene
Top achievements
Rank 1
Gene asked on 15 Dec 2009, 11:31 PM
I have a Radgrid with a GridClientSelectColumn.  I need to default the header and all row checkboxes to checked = true. 

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Dec 2009, 04:21 AM
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.
Tags
Grid
Asked by
Gene
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or