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

GridClientSelectColumn

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 03 Sep 2008, 05:24 PM
Hello,

Is there a way to link a GridClientSelectColumn to a DataSet?  I read through the documentation and the DataField property is not included, but I would like to be able to bind data with the column if possible.

I would use a GridCheckBoxColumn, however our users would like to be able to see which columns are selected for visualization, so I chose the GridClientSelectColumn.

If it is not possible, is there a way to use the GridCheckBoxColumn, but perform the same functionality as the GridClientSelectColumn?

Thank you,
Mike

3 Answers, 1 is accepted

Sort by
0
andy
Top achievements
Rank 1
answered on 03 Sep 2008, 07:39 PM

use gridTemplateColumn

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/SelectRowWithCheckBox/DefaultCS.aspx

As for binding, just add the checked = '<% Eval("bool")%>' into the Sample Code given by the demo.

<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" AllowFiltering = "false">  
                            <HeaderTemplate> 
<asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox> 
                            </HeaderTemplate> 
                            <ItemTemplate> 
<asp:CheckBox id="CheckBox1" Checked='<%# Eval("Bool") %>' AutoPostBack="False" runat="server"></asp:CheckBox> 
                            </ItemTemplate> 
</telerik:GridTemplateColumn> 
 
 

        Protected Sub ToggleRowSelection(ByVal sender As Object, ByVal e As EventArgs)
            CType(CType(sender, CheckBox).Parent.Parent, GridItem).Selected = CType(sender, CheckBox).Checked
        End Sub


        Protected Sub ToggleSelectedState(ByVal sender As Object, ByVal e As EventArgs)
            If (CType(sender, CheckBox)).Checked Then
                For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
                    CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = True
                    dataItem.Selected = True
                Next
            Else
                For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
                    CType(dataItem.FindControl("CheckBox1"), CheckBox).Checked = False
                    dataItem.Selected = False
                Next
            End If
        End Sub

0
Shinu
Top achievements
Rank 2
answered on 04 Sep 2008, 05:22 AM
Hi Mike,

You can also refer the following code library submission.
Check/Uncheck all checkboxes in template column and selecting rows with checkbox

Thanks
Shinu.
0
Mike
Top achievements
Rank 1
answered on 04 Sep 2008, 02:47 PM
Thank you both for the examples.  I like solution 2 because I want to avoid using a postback due to the fact I will be working with massive amounts of data.

My only other question is in the client side function CheckAll() is there a way to have it highlight the item when it is checked.

Basically if a dataitem is checked I would like it to be highlighted as well.

Thank you!
Mike
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
andy
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or