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

About GridViewSelectColumn

1 Answer 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yang
Top achievements
Rank 1
yang asked on 25 Jul 2011, 04:09 AM
1.
<telerik:RadGridView >
    <telerik:RadGridView.Columns>
           <telerik:GridViewSelectColumn/>
           <telerik:GridViewDataColumn Header="登陆名"  HeaderTextAlignment="Center" DataMemberBinding="{Binding EmployeeId}" Width="100">
           <telerik:GridViewDataColumn.AggregateFunctions>
           <telerik:CountFunction Caption="记录数: "    />
           </telerik:GridViewDataColumn.AggregateFunctions>
           </telerik:GridViewDataColumn>
           <telerik:GridViewDataColumn Header="姓名"   HeaderTextAlignment="Center"  DataMemberBinding="{Binding EmployeeName}" Width="200" />
       </telerik:RadGridView.Columns>
</telerik:RadGridView>

Question 1 :About <telerik:GridViewSelectColumn/>.How to add a label on the front of checkbox of header?


2.
<telerik:GridViewDataColumn Header="拖放" HeaderTextAlignment="Center"  
          DataMemberBinding="{Binding ISDrag,Mode=TwoWay}" Width="50">
      <telerik:GridViewDataColumn.CellTemplate>
                   <DataTemplate>
                         <CheckBox IsChecked="{Binding ISDrag,Mode=TwoWay}" IsEnabled="True"/>
                   </DataTemplate>
      </telerik:GridViewDataColumn.CellTemplate>
      <telerik:GridViewDataColumn.CellEditTemplate>
                  <DataTemplate>
                        <CheckBox Margin="5, 0, 0, 0" VerticalAlignment="Center" IsChecked="{Binding ISDrag,Mode=TwoWay}"/>
                   </DataTemplate>
        </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

How to add a checkboxon the back of checkbox of Header(Header="拖放"), And implement All-selected,All-Not-Selected ?
I find label and checkbox not exist Simultaneously.








1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Jul 2011, 09:24 AM
Hello Yang,

Indeed, when you define a custom header for the GridViewSelectColumn, the default one will be overridden. A possible approach would be to define a CheckBox in the header as well and handle its Click event as follows:

XAML:
<telerik:GridViewSelectColumn >
                    <telerik:GridViewSelectColumn.Header>
                        <StackPanel HorizontalAlignment="Center">
                            <TextBlock Text="Select/DeselectAll" />
                            <CheckBox Click="CheckBox_Click" />
                        </StackPanel>
                    </telerik:GridViewSelectColumn.Header>
                </telerik:GridViewSelectColumn>
 
C#:
 private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox headerCheckBox = sender as CheckBox;
            if (headerCheckBox.IsChecked == true)
            {
                this.clubsGrid.SelectAll();
            }
            else if (headerCheckBox.IsChecked == false)
            {
                this.clubsGrid.UnselectAll();
            }
        }

Another possible approach would be to create your own custom column with the exact functionality you require. Please take a look at this forum thread for a reference. 

Kind regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
yang
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or