I have a radGrid in a user control that I am basically using as a way for the user to select a list of companies and cost centers for which they want combined into a report. I am using the "Grid / Client-side Row Selection" grid 2 as an example.
The purpose of my user control is to return a string containing an XML representation of the selected items. The first column in my grid is a GridClientSelectColumn. If I click on the checkbox in the header, it selects all items, but if I uncheck one of the items, it does not uncheck the checkbox in the headers. This works in the sample mentioned above.
My user control looks like:
and my code-behind looks like:
I don't see anything different in the example that would cause the checkbox in the header to be not cleared when I uncheck a row. Any ideas?
Also, is it possible to check to see what the status of the checkbox in the header is? If I knew that the checkbox in the header was checked - and the above problem is resolved ;^) - then I would not need to process each record. I could simply return a different value to indicate that all rows are selected.
Thanks!
The purpose of my user control is to return a string containing an XML representation of the selected items. The first column in my grid is a GridClientSelectColumn. If I click on the checkbox in the header, it selects all items, but if I uncheck one of the items, it does not uncheck the checkbox in the headers. This works in the sample mentioned above.
My user control looks like:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="gridEntitiesAndCCs.ascx.vb" Inherits="gridEntitiesAndCCs" %>
<
link
href
=
"CTM.css"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
telerik:RadGrid
ID
=
"gridEntitiesAndCCs"
runat
=
"server"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"true"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
>
<
MasterTableView
DataKeyNames
=
"EntityID,CostCtr"
AllowMultiColumnSorting
=
"true"
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"clientSelect"
>
<
ItemStyle
Width
=
"25"
/>
</
telerik:GridClientSelectColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShortName"
HeaderText
=
"Entity"
SortExpression
=
"ShortName"
UniqueName
=
"ShortName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CostCtr"
HeaderText
=
"Cost Center"
SortExpression
=
"CostCtr"
UniqueName
=
"CostCtr"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DeptName"
HeaderText
=
"Dept Name"
SortExpression
=
"DeptName"
UniqueName
=
"DeptName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
and my code-behind looks like:
Partial Class gridEntitiesAndCCs
Inherits System.Web.UI.UserControl
Public ReadOnly Property selectedValues() As String
Get
Return Me.getCheckedRowDetails()
End Get
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub gridEntitiesAndCCs_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gridEntitiesAndCCs.NeedDataSource
Dim ds As DataSet = MM.getUserEntitiesAndCostCenters()
gridEntitiesAndCCs.DataSource = ds
End Sub
Private Function getCheckedRowDetails() As String
Dim row As GridItem
Dim entityID As String
Dim costCtr As String
Dim dstCCs As New DataSet
Dim dtblCCs As DataTable = New DataTable("EntsCCs")
dstCCs.Tables.Add(dtblCCs)
dtblCCs.Columns.Add(New DataColumn("entityID", GetType(String)))
dtblCCs.Columns.Add(New DataColumn("costCtr", GetType(String)))
Dim drowItem As DataRow
For Each row In gridEntitiesAndCCs.SelectedItems
entityID = row.OwnerTableView.DataKeyValues(row.ItemIndex)("EntityID")
costCtr = row.OwnerTableView.DataKeyValues(row.ItemIndex)("CostCtr")
drowItem = dtblCCs.NewRow()
drowItem("entityID") = entityID
drowItem("costCtr") = costCtr
dtblCCs.Rows.Add(drowItem)
Next
Return dstCCs.GetXml()
End Function
End Class
I don't see anything different in the example that would cause the checkbox in the header to be not cleared when I uncheck a row. Any ideas?
Also, is it possible to check to see what the status of the checkbox in the header is? If I knew that the checkbox in the header was checked - and the above problem is resolved ;^) - then I would not need to process each record. I could simply return a different value to indicate that all rows are selected.
Thanks!