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

check box checked by default when no records

4 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saran kumar
Top achievements
Rank 1
Saran kumar asked on 28 Jan 2010, 06:53 AM
hi please see attachment, here i used checkbox column where the check box is checked by default when ther is no records in the grid. please help to remove the default check.

<telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-Width="25px" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center" 
                                HeaderStyle-CssClass="radgridleftmostColumn" HeaderStyle-VerticalAlign="Middle" /> 

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 28 Jan 2010, 08:51 AM
Hello Saran,

I was able to replicate the same issue at my end. You can work around this using the following code:
aspx:
<asp:HiddenField ID="HiddenField1" runat="server" /> 

c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        GridHeaderItem header = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0]; 
        string clientid = ((CheckBox)header["CheckboxSelectColumn"].Controls[0]).ClientID; 
        HiddenField1.Value = clientid; 
    } 

js:
<script type="text/javascript"
function GridCreated() 
   var hiddenfield = document.getElementById("HiddenField1"); 
   var control = document.getElementById(hiddenfield.value); 
   control.checked = false
 
</script> 

Thanks
Princy.
0
Saran kumar
Top achievements
Rank 1
answered on 28 Jan 2010, 09:24 AM
hi Princy thanks for your reply.

but here when the JS GridCreated() get fired?. i got the clent id and putten the hidden field. but the js is not fired.i put alert inside it. could u tell me where it should be handled?

0
Princy
Top achievements
Rank 1
answered on 28 Jan 2010, 10:50 AM
Hi,

Make sure that you have attached the gridCreated client event handler as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server"
   <ClientSettings
        <ClientEvents OnGridCreated="GridCreated"/> 
   </ClientSettings> 
          .......... 

-Princy.
0
Saran kumar
Top achievements
Rank 1
answered on 28 Jan 2010, 01:30 PM
hi princy,

i already handled it in oncolumncreated, any way both dont have much difference i think.
 thanks for your timely responce.
Tags
Grid
Asked by
Saran kumar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Saran kumar
Top achievements
Rank 1
Share this question
or