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

GridClientSelectColumn header checkbox does not clear

4 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve LaForge
Top achievements
Rank 1
Steve LaForge asked on 22 Jul 2010, 12:46 AM
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:
<%@ 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!


4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 22 Jul 2010, 10:44 AM
Hi Steve,

For more information about how to achieve the desired functionality, please refer to the following code library:
GridClientSelectColumn -- (un)check "Select All" check box automatically

Give it a try and let me know if you need additional assistance.

Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Steve LaForge
Top achievements
Rank 1
answered on 23 Jul 2010, 06:28 PM
Thanks for the reponse, but this didn't help.  If you will please look at the example that I referenced you'll see that there is not any additional client or server side code for this functionality.  I checked the sample code library that ships with the product just to be sure that the code that I see on the website matches.  Also, if you look at the article that you linked, it doesn't actually update the checkbox in the header.  It is updating a hidden field only.

I found the issue, and this appears to be a bug to me.  It works just like the example says until I enable UseStaticHeaders.  Then it quits.  I can "almost" fix it by setting ClientSettings > EnablePostBackOnRowClick to true, but that means a server event which I don't like either.

The page that you referenced did however point me in the right direction for finding out if all items are selected.  In my button click event, I just needed to:

If gridEntitiesAndCCs.SelectedItems.Count = gridEntitiesAndCCs.Items.Count Then
  strWork = "<p>All items are selected</p>"
Else
  strWork = "<p>Not all items are selected</p>"
End If


0
Tsvetoslav
Telerik team
answered on 29 Jul 2010, 07:11 AM
Hello Steve,

You are correct in your observation. The difference between your set up for the grid and the online example is the use of static headers in your case. This evidently breaks the desired selection functionality. We shall be looking further into this issue and getting back to you with the results.

Thanks for the understanding.

Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tsvetoslav
Telerik team
answered on 10 Aug 2010, 09:42 AM
Hi Steve,

As a follow-up to my promise to keep you updated on the issue under discussion, I am glad to inform you that our development team has managed to address the problem and the fix should already been available in the latest internal build of the controls. Your telerik points have been updated accrodingly.

Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Steve LaForge
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Steve LaForge
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or