hello.. i m using telerik grid..grid havin three checkbox in threee columns..i want user can be able to select single checkbox at a time..
<himani:HimaniGrid ID="EmployeeAttendanceGrid" runat="server" GridLines="None" |
AutoGenerateColumns="False" |
onitemcommand="EmployeeAttendanceGrid_ItemCommand" |
onitemdatabound="EmployeeAttendanceGrid_ItemDataBound"> |
<MasterTableView cellspacing="-1"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<himani:GridTemplateColumn Visible="false"> |
<ItemTemplate> |
<asp:Label ID="LbEmployeeid" runat="server" Text='<%#Eval("ID")%>'></asp:Label> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
<himani:GridTemplateColumn HeaderText="Employee Name"> |
<ItemTemplate> |
<asp:Label ID="Label2" runat="server" Text='<%#Eval("NAME")%>'></asp:Label> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
<himani:GridTemplateColumn HeaderText="Present" > |
<ItemTemplate> |
<asp:CheckBox ID="ChkPresent" runat="server" /> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
<himani:GridTemplateColumn HeaderText="Absent" > |
<ItemTemplate> |
<asp:CheckBox ID="ChkAbsent" runat="server" /> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
<himani:GridTemplateColumn HeaderText="Leave" > |
<ItemTemplate> |
<asp:CheckBox ID="Chkleave" runat="server" /> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
<himani:GridTemplateColumn> |
<ItemTemplate> |
<asp:Button ID="btnView" runat="server" Text="View" /> |
</ItemTemplate> |
</himani:GridTemplateColumn> |
</Columns> |
</MasterTableView> |
</himani:HimaniGrid> |
<script language="javascript" type="text/javascript"> |
function check(ChkPresent,ChkAbsent, Chkleave, currentCheckBoxClicked) { |
var objC1 = document.getElementById(ChkPresent); |
var objC2 = document.getElementById(ChkAbsent); |
var objC3 = document.getElementById(Chkleave); |
if (ChkPresent== currentCheckBoxClicked) { |
objC2.checked = false; |
objC3.checked = false; |
} |
else if (ChkAbsent == currentCheckBoxClicked) { |
objC1.checked = false; |
objC3.checked = false; |
} |
else if (Chkleave == currentCheckBoxClicked) { |
objC1.checked = false; |
objC2.checked = false; |
} |
} |
</script> |
protected void EmployeeAttendanceGrid_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
//GridDataItem item = (GridDataItem)(((CheckBox)e.CommandSource).NamingContainer); |
if(e.Item.ItemType==Himani.Web.UI.GridItemType.AlternatingItem) |
//if (e.Row.RowType == DataControlRowType.DataRow) |
{ |
CheckBox c1 = e.Item.FindControl("ChkPresent") as CheckBox; |
CheckBox c2 = e.Item.FindControl("ChkAbsent") as CheckBox; |
CheckBox c3 = e.Item.FindControl("Chkleave") as CheckBox; |
c1.Attributes.Add("onclick", "javascript:check('" + c1.ClientID + "','" + c2.ClientID + "','" + c3.ClientID + "',this.id);"); |
c2.Attributes.Add("onclick", "javascript:check('" + c1.ClientID + "','" + c2.ClientID + "','" + c3.ClientID + "',this.id);"); |
c3.Attributes.Add("onclick", "javascript:check('" + c1.ClientID + "','" + c2.ClientID + "','" + c3.ClientID + "',this.id);"); |
} |
} |
in second row it creating problem i able can select all checkbox