<telerik:GridCheckBoxColumn DataField="IsCustomer" SortExpression="IsCustomer" UniqueName="IsCustomer" DataType="System.Boolean" ReadOnly="true" Visible="false" ></telerik:GridCheckBoxColumn><telerik:GridDropDownColumn DataField="CustomerID" UniqueName="CustomerID" EnableEmptyListItem="True" > <HeaderStyle Width="120px" /> <ItemStyle Width="120px" /></telerik:GridDropDownColumn><telerik:GridDropDownColumn DataField="ContactID" UniqueName="ContactID" EnableEmptyListItem="True" > <HeaderStyle Width="100px" /> <ItemStyle Width="100px" /></telerik:GridDropDownColumn>Protected Sub rgOpportunities_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgOpportunities.ItemDataBound If (TypeOf e.Item Is GridDataItem) Then 'If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then Dim editFormItem As GridDataItem = CType(e.Item, GridDataItem) Dim Cus As GridDropDownColumn = CType(rgOpportunities.MasterTableView.Columns(8), GridDropDownColumn) Dim Con As GridDropDownColumn = CType(rgOpportunities.MasterTableView.Columns(9), GridDropDownColumn) If DirectCast(editFormItem("IsCustomer").Controls(0), CheckBox).Checked = True Then Cus.DataSourceID = "odsCustomer" Cus.ListTextField = "Name" Cus.ListValueField = "CustomerID" Con.DataSourceID = "odsContact" Con.ListTextField = "Name" Con.ListValueField = "ContactID" Else Cus.DataSourceID = "odsLeadHdr" Cus.ListTextField = "Name" Cus.ListValueField = "LeadHdrID" Con.DataSourceID = "odsLeadDtl" Con.ListTextField = "Name" Con.ListValueField = "LeadDtlID" End If End IfEnd SubHere is the js code:
function SelectAllCheckedChanged() {
var grid = window['<%= rgManufacturerDisplay.ClientID %>'];
var inputElements = grid.MasterTableView.Control.getElementsByTagName("INPUT");
var headerChecked = window.event.srcElement.checked;
var index;
for (index = 0; index < inputElements.length; index++) {
//NOTE: The GetElementsByTagName("INPUT") will return ALL input controls in the grid, so we have
//to filter to the ones that we specfically care about.
if (inputElements[index].id.indexOf("chkDistributor") != -1) {
//If the id of the control is "chkDistributor" then this is the checkbox in the Select column
//for the grid row and we need to check/uncheck it (only if it's enabled).
if (!inputElements[index].disabled) {
inputElements[index].checked = headerChecked;
}
}
}
}
<telerik:RadGrid ID="rg" runat="server" Skin="Office2010Silver" OnNeedDataSource="rg_NeedDataSource"OnItemCommand="rgScores_ItemCommand"><ExportSettings HideStructureColumns="true" /><MasterTableView AllowPaging="true" AllowSorting="true" Width="100%" CommandItemDisplay="Top"><CommandItemSettings ShowExportToExcelButton="true" ShowRefreshButton="false" ShowAddNewRecordButton="false" /></MasterTableView></telerik:RadGrid><script type="text/javascript"> function RequestStart(sender, args) { if (args.EventTarget == "Button1") { args.EnableAjax = false; } } </script>